$fixtureManager
$fixtureManager : \Cake\TestSuite\Fixture\FixtureManager|null
The class responsible for managing the creation, loading and removing of fixtures
Cake TestCase class
$fixtureManager : \Cake\TestSuite\Fixture\FixtureManager|null
The class responsible for managing the creation, loading and removing of fixtures
$_tableLocator : \Cake\ORM\Locator\LocatorInterface
Table locator instance
tableLocator(\Cake\ORM\Locator\LocatorInterface|null $tableLocator = null) : \Cake\ORM\Locator\LocatorInterface
Sets the table locator.
If no parameters are passed, it will return the currently used locator.
\Cake\ORM\Locator\LocatorInterface|null | $tableLocator | LocatorInterface instance. |
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator) : $this
Sets the table locator.
\Cake\ORM\Locator\LocatorInterface | $tableLocator | LocatorInterface instance. |
None found |
getTableLocator() : \Cake\ORM\Locator\LocatorInterface
Gets the table locator.
None found |
skipIf(boolean $shouldSkip, string $message = '') : boolean
Overrides SimpleTestCase::skipIf to provide a boolean return value
boolean | $shouldSkip | Whether or not the test should be skipped. |
string | $message | The message to display. |
None found |
withErrorReporting(integer $errorLevel, callable $callable) : void
Helper method for tests that needs to use error_reporting()
integer | $errorLevel | value of error_reporting() that needs to use |
callable | $callable | callable function that will receive asserts |
None found |
deprecated(callable $callable) : void
Helper method for check deprecation methods
callable | $callable | callable function that will receive asserts |
None found |
setUp() : void
Setup the test case, backup the static object values so they can be restored.
Specifically backs up the contents of Configure and paths in App if they have not already been backed up.
None found |
None found |
loadFixtures() : void
Chooses which fixtures to load for a given test
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.
when no fixture manager is available.
None found |
loadPlugins(array $plugins = array()) : \Cake\Http\BaseApplication
Load plugins into a simulated application.
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
array | $plugins | list of Plugins to load |
None found |
removePlugins(array $plugins = array()) : void
Remove plugins from the global plugin collection.
Useful in test case teardown methods.
array | $plugins | A list of plugins you want to remove. |
None found |
clearPlugins() : void
Clear all plugins from the global plugin collection.
Useful in test case teardown methods.
None found |
assertEventFired(string $name, \Cake\Event\EventManager|null $eventManager = null, string $message = '') : void
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
string | $name | Event name |
\Cake\Event\EventManager|null | $eventManager | Event manager to check, defaults to global event manager |
string | $message | Assertion failure message |
None found |
assertEventFiredWith(string $name, string $dataKey, string $dataValue, \Cake\Event\EventManager|null $eventManager = null, string $message = '') : void
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
string | $name | Event name |
string | $dataKey | Data key |
string | $dataValue | Data value |
\Cake\Event\EventManager|null | $eventManager | Event manager to check, defaults to global event manager |
string | $message | Assertion failure message |
None found |
assertTextNotEquals(string $expected, string $result, string $message = '') : void
Assert text equality, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $expected | The expected value. |
string | $result | The actual value. |
string | $message | The message to use for failure. |
None found |
assertTextEquals(string $expected, string $result, string $message = '') : void
Assert text equality, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $expected | The expected value. |
string | $result | The actual value. |
string | $message | The message to use for failure. |
None found |
assertTextStartsWith(string $prefix, string $string, string $message = '') : void
Asserts that a string starts with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $prefix | The prefix to check for. |
string | $string | The string to search in. |
string | $message | The message to use for failure. |
None found |
assertTextStartsNotWith(string $prefix, string $string, string $message = '') : void
Asserts that a string starts not with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $prefix | The prefix to not find. |
string | $string | The string to search. |
string | $message | The message to use for failure. |
None found |
assertTextEndsWith(string $suffix, string $string, string $message = '') : void
Asserts that a string ends with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $suffix | The suffix to find. |
string | $string | The string to search. |
string | $message | The message to use for failure. |
None found |
assertTextEndsNotWith(string $suffix, string $string, string $message = '') : void
Asserts that a string ends not with a given prefix, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $suffix | The suffix to not find. |
string | $string | The string to search. |
string | $message | The message to use for failure. |
None found |
assertTextContains(string $needle, string $haystack, string $message = '', boolean $ignoreCase = false) : void
Assert that a string contains another string, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $needle | The string to search for. |
string | $haystack | The string to search through. |
string | $message | The message to display on failure. |
boolean | $ignoreCase | Whether or not the search should be case-sensitive. |
None found |
assertTextNotContains(string $needle, string $haystack, string $message = '', boolean $ignoreCase = false) : void
Assert that a text doesn't contain another text, ignoring differences in newlines.
Helpful for doing cross platform tests of blocks of text.
string | $needle | The string to search for. |
string | $haystack | The string to search through. |
string | $message | The message to display on failure. |
boolean | $ignoreCase | Whether or not the search should be case-sensitive. |
None found |
assertTags(string $string, array $expected, boolean $fullDebug = false) : void
Asserts HTML tags.
string | $string | An HTML/XHTML/XML string |
array | $expected | An array, see above |
boolean | $fullDebug | Whether or not more verbose output should be used. |
None found |
assertHtml(array $expected, string $string, boolean $fullDebug = false) : boolean
Asserts HTML tags.
Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:
Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':
['input' => ['name', 'id' => 'my-input']]
Checks for two p elements with some text in them:
[
['p' => true],
'textA',
'/p',
['p' => true],
'textB',
'/p'
]
You can also specify a pattern expression as part of the attribute values, or the tag being defined, if you prepend the value with preg: and enclose it with slashes, like so:
[
['input' => ['name', 'id' => 'preg:/FieldName\d+/']],
'preg:/My\s+field/'
]
Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order. It will also allow whitespace between specified tags.
array | $expected | An array, see above |
string | $string | An HTML/XHTML/XML string |
boolean | $fullDebug | Whether or not more verbose output should be used. |
None found |
getMockForModel(string $alias, array|null $methods = array(), array $options = array()) : \Cake\ORM\Table|\PHPUnit_Framework_MockObject_MockObject
Mock a model, maintain fixtures and table association
string | $alias | The model to get a mock for. |
array|null | $methods | The list of methods to mock |
array | $options | The config data for the mock's constructor. |
None found |
setAppNamespace(string $appNamespace = 'TestApp') : void
Set the app namespace
string | $appNamespace | The app namespace, defaults to "TestApp". |
None found |
_assertAttributes(array $assertions, string $string, boolean $fullDebug = false, array|string $regex = '') : string|boolean
Check the attributes as part of an assertTags() check.
array | $assertions | Assertions to run. |
string | $string | The HTML string to check. |
boolean | $fullDebug | Whether or not more verbose output should be used. |
array|string | $regex | Full regexp from |
None found |
_normalizePath(string $path) : string
Normalize a path for comparison.
string | $path | Path separated by "/" slash. |
Normalized path separated by DIRECTORY_SEPARATOR.
None found |
assertWithinRange(float $expected, float $result, float $margin, string $message = '') : void
Compatibility function to test if a value is between an acceptable range.
float | $expected | |
float | $result | |
float | $margin | the rage of acceptation |
string | $message | the text to display if the assertion is not correct |
None found |
assertNotWithinRange(float $expected, float $result, float $margin, string $message = '') : void
Compatibility function to test if a value is not between an acceptable range.
float | $expected | |
float | $result | |
float | $margin | the rage of acceptation |
string | $message | the text to display if the assertion is not correct |
None found |
assertPathEquals(string $expected, string $result, string $message = '') : void
Compatibility function to test paths.
string | $expected | |
string | $result | |
string | $message | the text to display if the assertion is not correct |
None found |
skipUnless(boolean $condition, string $message = '') : boolean
Compatibility function for skipping.
boolean | $condition | Condition to trigger skipping |
string | $message | Message for skip |
None found |
_getTableClassName(string $alias, array $options) : string
Gets the class name for the table.
string | $alias | The model to get a mock for. |
array | $options | The config data for the mock's constructor. |
None found |