PHP Class CIPHPUnitTestDouble, ci-phpunit-test

Show file Open project: kenjis/ci-phpunit-test Class Usage Examples

Protected Properties

Property Type Description
$testCase

Public Methods

Method Description
__construct ( PHPUnit_Framework_TestCase $testCase )
getDouble ( string $classname, array $params, mixed $constructor_params = false ) : object Get Mock Object
verifyInvoked ( object $mock, string $method, array $params = null ) Verifies a method was invoked at least once
verifyInvokedMultipleTimes ( object $mock, string $method, integer $times, array $params = null ) Verifies that method was called exactly $times times
verifyInvokedOnce ( object $mock, string $method, array $params = null ) Verifies that method was invoked only once
verifyNeverInvoked ( object $mock, string $method, array $params = null ) Verifies that method was not called

Protected Methods

Method Description
_verify ( $mock, $method, $params = null, $expects, $with )

Method Details

__construct() public method

public __construct ( PHPUnit_Framework_TestCase $testCase )
$testCase PHPUnit_Framework_TestCase

_verify() protected method

protected _verify ( $mock, $method, $params = null, $expects, $with )

getDouble() public method

$email = $this->getMockBuilder('CI_Email') ->disableOriginalConstructor() ->setMethods(['send']) ->getMock(); $email->method('send')->willReturn(TRUE); will be $email = $this->getDouble('CI_Email', ['send' => TRUE]);
public getDouble ( string $classname, array $params, mixed $constructor_params = false ) : object
$classname string
$params array [method_name => return_value]
$constructor_params mixed false: disable construntor, array: construntor params
return object PHPUnit mock object

verifyInvoked() public method

Verifies a method was invoked at least once
public verifyInvoked ( object $mock, string $method, array $params = null )
$mock object PHPUnit mock object
$method string
$params array arguments

verifyInvokedMultipleTimes() public method

$loader->expects($this->exactly(2)) ->method('view') ->withConsecutive( ['shop_confirm', $this->anything(), TRUE], ['shop_tmpl_checkout', $this->anything()] ); will be $this->verifyInvokedMultipleTimes( $loader, 'view', 2, [ ['shop_confirm', $this->anything(), TRUE], ['shop_tmpl_checkout', $this->anything()] ] );
public verifyInvokedMultipleTimes ( object $mock, string $method, integer $times, array $params = null )
$mock object PHPUnit mock object
$method string
$times integer
$params array arguments

verifyInvokedOnce() public method

Verifies that method was invoked only once
public verifyInvokedOnce ( object $mock, string $method, array $params = null )
$mock object PHPUnit mock object
$method string
$params array arguments

verifyNeverInvoked() public method

Verifies that method was not called
public verifyNeverInvoked ( object $mock, string $method, array $params = null )
$mock object PHPUnit mock object
$method string
$params array arguments

Property Details

$testCase protected property

protected $testCase