Skip to content

CIPHPUnitTestDouble

Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CIPHPUnitTestDouble

Part of CI PHPUnit Test

  • Class name: CIPHPUnitTestDouble
  • Namespace:

Properties

$testCase

protected mixed $testCase
  • Visibility: protected

Methods

__construct

mixed CIPHPUnitTestDouble::__construct(\PHPUnit_Framework_TestCase $testCase)
  • Visibility: public

Arguments

  • $testCase PHPUnit_Framework_TestCase

getDouble

object CIPHPUnitTestDouble::getDouble(string $classname, array $params)

Get Mock Object

$email = $this->getMockBuilder('CI_Email') ->setMethods(['send']) ->getMock(); $email->method('send')->willReturn(TRUE);

will be

$email = $this->getDouble('CI_Email', ['send' => TRUE]);

  • Visibility: public

Arguments

  • $classname string
  • $params array - <p>[method_name => return_value]</p>

_verify

mixed CIPHPUnitTestDouble::_verify($mock, $method, $params, $expects, $with)
  • Visibility: protected

Arguments

  • $mock mixed
  • $method mixed
  • $params mixed
  • $expects mixed
  • $with mixed

verifyInvokedMultipleTimes

mixed CIPHPUnitTestDouble::verifyInvokedMultipleTimes(object $mock, string $method, integer $times, array $params)

Verifies that method was called exactly $times times

$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()] ] );

  • Visibility: public

Arguments

  • $mock object - <p>PHPUnit mock object</p>
  • $method string
  • $times integer
  • $params array - <p>arguments</p>

verifyInvoked

mixed CIPHPUnitTestDouble::verifyInvoked(object $mock, string $method, array $params)

Verifies a method was invoked at least once

  • Visibility: public

Arguments

  • $mock object - <p>PHPUnit mock object</p>
  • $method string
  • $params array - <p>arguments</p>

verifyInvokedOnce

mixed CIPHPUnitTestDouble::verifyInvokedOnce(object $mock, string $method, array $params)

Verifies that method was invoked only once

  • Visibility: public

Arguments

  • $mock object - <p>PHPUnit mock object</p>
  • $method string
  • $params array - <p>arguments</p>

verifyNeverInvoked

mixed CIPHPUnitTestDouble::verifyNeverInvoked(object $mock, string $method, array $params)

Verifies that method was not called

  • Visibility: public

Arguments

  • $mock object - <p>PHPUnit mock object</p>
  • $method string
  • $params array - <p>arguments</p>
Clone this wiki locally