ResultMockFactory
in package
An easy way to create Result objects for your tests.
Tags
Table of Contents
Methods
- create() : T
- Instantiate a Result class with some data.
- createFailing() : T
- Instantiate a Result class that throws exception.
- waiter() : T
- Instantiate a Waiter class with a final state.
- addPropertiesOnResult() : void
- Set input and aws client to handle pagination.
- addUndefinedProperties() : void
- Try to add some values to the properties not defined in $data.
- getResponseObject() : Response
Methods
create()
Instantiate a Result class with some data.
public
static create(T> $class[, array<string, mixed> $data = [] ]) : T
ResultMockFactory::create(SendEmailResponse::class, ['MessageId'=>'foo123']);
Parameters
- $class : T>
- $data : array<string, mixed> = []
Tags
Return values
TcreateFailing()
Instantiate a Result class that throws exception.
public
static createFailing(T> $class, int $code[, string|null $message = null ][, array<string, mixed> $additionalContent = [] ]) : T
ResultMockFactory::createFailing(SendEmailResponse::class, 400, 'invalid value');
Parameters
- $class : T>
- $code : int
- $message : string|null = null
- $additionalContent : array<string, mixed> = []
Tags
Return values
Twaiter()
Instantiate a Waiter class with a final state.
public
static waiter(string $class, string $finalState) : T
Parameters
- $class : string
- $finalState : string
Tags
Return values
TaddPropertiesOnResult()
Set input and aws client to handle pagination.
private
static addPropertiesOnResult(ReflectionClass<string|int, object> $reflectionClass, object $object, string $class) : void
Parameters
- $reflectionClass : ReflectionClass<string|int, object>
- $object : object
- $class : string
addUndefinedProperties()
Try to add some values to the properties not defined in $data.
private
static addUndefinedProperties(ReflectionClass<string|int, object> $reflectionClass, object $object, array<string, mixed> $data) : void
Parameters
- $reflectionClass : ReflectionClass<string|int, object>
- $object : object
- $data : array<string, mixed>
Tags
getResponseObject()
private
static getResponseObject() : Response