PHP Class lithium\test\MockerChain

Asserting if method1 was not called $mock = new \lithium\tests\mocks\test\mockStdClass\Mock(); $this->assertFalse(Mocker::chain($mock)->called('method1')->success()); Asserting if method1 was called 2 times $mock = new \lithium\tests\mocks\test\mockStdClass\Mock(); $this->assertTrue(Mocker::chain($mock)->called('method1')->eq(2)->success()); Asserting if method2 was called after method1 $mock = new \lithium\tests\mocks\test\mockStdClass\Mock(); $this->assertTrue(Mocker::chain($mock)->called('method1')->called('method2')->success()); Asserting if method2 was called after method1, and method2 had specific arguments. $mock = new \lithium\tests\mocks\test\mockStdClass\Mock(); $this->assertTrue(Mocker::chain($mock) ->called('method1') ->called('method2')->with('foo', 'bar') ->success());
Inheritance: extends lithium\core\Object
Show file Open project: unionofrad/lithium

Protected Properties

Property Type Description
$_data array results Cached mock results method Method we are asserting args Args we are asserting success Success flag callTime Last method call

Public Methods

Method Description
__call ( string $comparison, array $args ) : object Validates that a given methodis called a set number of times.
__construct ( array $results ) : void Constructor. Saves the results from the mock.
called ( string $method ) : object Valides the method was called after the last call.
respondsTo ( string $method, boolean $internal = false ) : boolean Determines if a given method can be called.
success ( ) : boolean Gives back the success flag
with ( ) : object Will further narrow down the original 'called' method.

Method Details

__call() public method

Validates that a given methodis called a set number of times.
public __call ( string $comparison, array $args ) : object
$comparison string Comparison type 'gt', 'gte', 'lt', 'lte', or 'eq'.
$args array The first argument is the expected result.
return object

__construct() public method

Constructor. Saves the results from the mock.
public __construct ( array $results ) : void
$results array Results from the mock
return void

called() public method

Valides the method was called after the last call.
public called ( string $method ) : object
$method string Method to assert
return object

respondsTo() public method

Determines if a given method can be called.
public respondsTo ( string $method, boolean $internal = false ) : boolean
$method string Name of the method.
$internal boolean Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`.
return boolean Returns `true` if the method can be called, `false` otherwise.

success() public method

Gives back the success flag
public success ( ) : boolean
return boolean

with() public method

Valides the cached method name was called with these args
public with ( ) : object
return object

Property Details

$_data protected property

results Cached mock results method Method we are asserting args Args we are asserting success Success flag callTime Last method call
protected array $_data
return array