PHP Class CIPHPUnitTestCase, ci-phpunit-test

Inheritance: extends PHPUnit_Framework_TestCase
Datei anzeigen Open project: kenjis/ci-phpunit-test Class Usage Examples

Protected Properties

Property Type Description
$CI CodeIgniter instance
$_error_reporting
$backupGlobalsBlacklist array You would see Exception: Serialization of 'Closure' is not allowed.
$class_map

Public Methods

Method Description
__get ( $name )
ajaxRequest ( string $http_method, array | string $argv, array $params = [] ) Request to Controller using ajax request
assertRedirect ( string $uri, integer $code = null ) Asserts Redirect
assertResponseCode ( integer $code ) Asserts HTTP response code
assertResponseCookie ( string $name, string | array $value, boolean $allow_duplicate = false ) Asserts HTTP response cookie
assertResponseHeader ( string $name, string $value ) Asserts HTTP response header
getDouble ( string $classname, array $params, boolean $enable_constructor = false ) : object Get Mock Object
newController ( string $classname ) : CI_Controller Create a controller instance
request ( string $http_method, array | string $argv, array $params = [] ) Request to Controller
resetInstance ( ) Reset CodeIgniter instance and assign new CodeIgniter instance as $this->CI
setCI ( CI_Controller $CI )
setUpBeforeClass ( )
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
warningOff ( )
warningOn ( )

Protected Methods

Method Description
tearDown ( )

Method Details

__get() public method

public __get ( $name )

ajaxRequest() public method

Request to Controller using ajax request
public ajaxRequest ( string $http_method, array | string $argv, array $params = [] )
$http_method string HTTP method
$argv array | string array of controller,method,arg|uri
$params array POST parameters/Query string

assertRedirect() public method

Asserts Redirect
public assertRedirect ( string $uri, integer $code = null )
$uri string URI to redirect
$code integer response code

assertResponseCode() public method

Asserts HTTP response code
public assertResponseCode ( integer $code )
$code integer

assertResponseCookie() public method

Asserts HTTP response cookie
public assertResponseCookie ( string $name, string | array $value, boolean $allow_duplicate = false )
$name string cookie name
$value string | array cookie value|array of cookie params
$allow_duplicate boolean whether to allow duplicated cookies

assertResponseHeader() public method

Asserts HTTP response header
public assertResponseHeader ( string $name, string $value )
$name string header name
$value string header value

getDouble() public method

$email = $this->getMockBuilder('CI_Email') ->setMethods(['send']) ->getMock(); $email->method('send')->willReturn(TRUE); will be $email = $this->getDouble('CI_Email', ['send' => TRUE]);
public getDouble ( string $classname, array $params, boolean $enable_constructor = false ) : object
$classname string
$params array [method_name => return_value]
$enable_constructor boolean enable constructor or not
return object PHPUnit mock object

newController() public method

Create a controller instance
public newController ( string $classname ) : CI_Controller
$classname string
return CI_Controller

request() public method

Request to Controller
public request ( string $http_method, array | string $argv, array $params = [] )
$http_method string HTTP method
$argv array | string array of controller,method,arg|uri
$params array POST parameters/Query string

resetInstance() public method

Reset CodeIgniter instance and assign new CodeIgniter instance as $this->CI
public resetInstance ( )

setCI() public method

public setCI ( CI_Controller $CI )
$CI CI_Controller

setUpBeforeClass() public static method

public static setUpBeforeClass ( )

tearDown() protected method

protected tearDown ( )

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

warningOff() public method

public warningOff ( )

warningOn() public method

public warningOn ( )

Property Details

$CI protected_oe property

CodeIgniter instance
protected $CI

$_error_reporting protected_oe property

protected $_error_reporting

$backupGlobalsBlacklist protected_oe property

You would see Exception: Serialization of 'Closure' is not allowed.
protected array $backupGlobalsBlacklist
return array

$class_map protected_oe property

protected $class_map