PHP Класс AppTestCase

Наследование: extends BaseDbTestCase
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$dependedFixtures array Fixtures
$fixtures array Fixtures
$plugin string Autoload entrypoint for fixtures dependecy solver

Защищенные свойства (Protected)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
_validData ( Model $Model, array $data, array &$validationErrors = [] ) : boolean Convenience method allowing to validate data and return the result

Описание методов

__construct() публичный Метод

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
Результат void

_validData() защищенный Метод

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
Результат boolean Return value of Model::validate()

assertFalse() публичный статический Метод

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

assertInvalid() публичный Метод

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
Результат void

assertIsA() публичный статический Метод

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

assertNotA() публичный статический Метод

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

assertTrue() публичный статический Метод

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

assertValid() публичный Метод

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
Результат void

assertValidationErrors() публичный Метод

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
Результат void

getTests() публичный Метод

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
Результат array List of tests to run

loadConfig() публичный Метод

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.
Результат mixed false if file not found, void if load successful

mockCakeEmail() публичный Метод

Provides conventional method to mock CakeEmail object
public mockCakeEmail ( ) : PHPUnit_Framework_MockObject_MockObject
Результат PHPUnit_Framework_MockObject_MockObject

pass() публичный Метод

public pass ( $message = '' )

solveDependancies() публичный Метод

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
Результат array Array of plugins that this plugin's test cases depend on.

Описание свойств

$_testsToRun защищенное свойство

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
Результат array

$dependedFixtures публичное свойство

Fixtures
public array $dependedFixtures
Результат array

$fixtures публичное свойство

Fixtures
public array $fixtures
Результат array

$plugin публичное свойство

Autoload entrypoint for fixtures dependecy solver
public string $plugin
Результат string