PHP Class AppTestCase

Inheritance: extends BaseDbTestCase
Show file Open project: cakedc/templates Class Usage Examples

Public Properties

Property Type Description
$dependedFixtures array Fixtures
$fixtures array Fixtures
$plugin string Autoload entrypoint for fixtures dependecy solver

Protected Properties

Property Type Description
$_testsToRun array Test to run for the test case (e.g array('testFind', 'testView')) If this attribute is not empty only the tests from the list will be executed

Public Methods

Method Description
__construct ( $name = null, array $data = [], $dataName = '' ) : void Constructor
assertFalse ( $condition, $message = '' )
assertInvalid ( Model $Model, array $data ) : void Asserts that data are invalid given Model validation rules Calls the Model::validate() method and asserts the result
assertIsA ( $actual, $expected, $message = '' )
assertNotA ( $actual, $expected, $message = '' )
assertTrue ( $condition, $message = '' )
assertValid ( Model $Model, array $data ) : void Asserts that data are valid given Model validation rules Calls the Model::validate() method and asserts the result
assertValidationErrors ( Model $Model, array $data, array $expectedErrors ) : void Asserts that data are validation errors match an expected value when validation given data for the Model Calls the Model::validate() method and asserts validationErrors
getTests ( ) : array Overrides parent method to allow selecting tests to run in the current test case It is useful when working on one particular test
loadConfig ( string $fileName, string $type = 'app' ) : mixed Loads a file from app/tests/config/configure_file.php or app/plugins/PLUGIN/tests/config/configure_file.php
mockCakeEmail ( ) : PHPUnit_Framework_MockObject_MockObject Provides conventional method to mock CakeEmail object
pass ( $message = '' )
solveDependancies ( string $plugin ) : array Solves Plugin Fixture dependancies. Called in AppTestCase::__construct to solve fixture dependancies. Uses a Plugins tests/config/dependent and tests/config/fixtures to load plugin fixtures. To use this feature set $plugin = 'pluginName' in your test case.

Protected Methods

Method Description
_validData ( Model $Model, array $data, array &$validationErrors = [] ) : boolean Convenience method allowing to validate data and return the result

Method Details

__construct() public method

If a class is extending AppTestCase it will merge these with the extending classes so that you don't have to put the plugin fixtures into the AppTestCase
public __construct ( $name = null, array $data = [], $dataName = '' ) : void
$data array
return void

_validData() protected method

Convenience method allowing to validate data and return the result
protected _validData ( Model $Model, array $data, array &$validationErrors = [] ) : boolean
$Model Model Model being tested
$data array Profile data
$validationErrors array Validation errors: this variable will be updated with validationErrors (sorted by key) in case of validation fail
return boolean Return value of Model::validate()

assertFalse() public static method

public static assertFalse ( $condition, $message = '' )

assertInvalid() public method

Asserts that data are invalid given Model validation rules Calls the Model::validate() method and asserts the result
public assertInvalid ( Model $Model, array $data ) : void
$Model Model Model being tested
$data array Data to validate
return void

assertIsA() public static method

public static assertIsA ( $actual, $expected, $message = '' )

assertNotA() public static method

public static assertNotA ( $actual, $expected, $message = '' )

assertTrue() public static method

public static assertTrue ( $condition, $message = '' )

assertValid() public method

Asserts that data are valid given Model validation rules Calls the Model::validate() method and asserts the result
public assertValid ( Model $Model, array $data ) : void
$Model Model Model being tested
$data array Data to validate
return void

assertValidationErrors() public method

Asserts that data are validation errors match an expected value when validation given data for the Model Calls the Model::validate() method and asserts validationErrors
public assertValidationErrors ( Model $Model, array $data, array $expectedErrors ) : void
$Model Model Model being tested
$data array Data to validate
$expectedErrors array Expected errors keys
return void

getTests() public method

Overrides parent method to allow selecting tests to run in the current test case It is useful when working on one particular test
public getTests ( ) : array
return array List of tests to run

loadConfig() public method

Config file variables should be formated like: $config['name'] = 'value'; These will be used to create dynamic Configure vars.
public loadConfig ( string $fileName, string $type = 'app' ) : mixed
$fileName string name of file to load, extension must be .php and only the name should be used, not the extenstion.
$type string Type of config file being loaded. If equal to 'app' core config files will be use. if $type == 'pluginName' that plugins tests/config files will be loaded.
return mixed false if file not found, void if load successful

mockCakeEmail() public method

Provides conventional method to mock CakeEmail object
public mockCakeEmail ( ) : PHPUnit_Framework_MockObject_MockObject
return PHPUnit_Framework_MockObject_MockObject

pass() public method

public pass ( $message = '' )

solveDependancies() public method

Solves Plugin Fixture dependancies. Called in AppTestCase::__construct to solve fixture dependancies. Uses a Plugins tests/config/dependent and tests/config/fixtures to load plugin fixtures. To use this feature set $plugin = 'pluginName' in your test case.
public solveDependancies ( string $plugin ) : array
$plugin string Name of the plugin to load
return array Array of plugins that this plugin's test cases depend on.

Property Details

$_testsToRun protected property

Test to run for the test case (e.g array('testFind', 'testView')) If this attribute is not empty only the tests from the list will be executed
protected array $_testsToRun
return array

$dependedFixtures public property

Fixtures
public array $dependedFixtures
return array

$fixtures public property

Fixtures
public array $fixtures
return array

$plugin public property

Autoload entrypoint for fixtures dependecy solver
public string $plugin
return string