Cake TestCase class
$_configure
protected array
$_pathRestore
protected array
$autoFixtures
public boolean
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
$dropTables
public boolean
$fixtureManager
public Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
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.
_assertAttributes( array $assertions , string $string , boolean $fullDebug false , array|string $regex '' )
Check the attributes as part of an assertTags() check.
$assertions
$string
$fullDebug
optional false $regex
optional '' assertHtml
_normalizePath( string $path )
Normalize a path for comparison.
$path
assertEventFired( string $name , Cake\Event\EventManager|null $eventManager null , string $message '' )
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
$name
Cake\Event\EventManager
|null $eventManager
optional null $message
optional '' assertEventFiredWith( string $name , string $dataKey , string $dataValue , Cake\Event\EventManager|null $eventManager null , string $message '' )
Asserts an event was fired with data
If a third argument is passed, that value is used to compare with the value in $dataKey
$name
$dataKey
$dataValue
Cake\Event\EventManager
|null $eventManager
optional null $message
optional '' assertHtml( array $expected , string $string , boolean $fullDebug false )
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.
$expected
$string
$fullDebug
optional false assertNotWithinRange( float $expected , float $result , float $margin , string $message '' )
Compatibility function to test if a value is not between an acceptable range.
$expected
$result
$margin
$message
optional '' assertPathEquals( string $expected , string $result , string $message '' )
Compatibility function to test paths.
$expected
$result
$message
optional '' assertTags( string $string , array $expected , boolean $fullDebug false )
Asserts HTML tags.
$string
$expected
$fullDebug
optional false assertTextContains( string $needle , string $haystack , string $message '' , boolean $ignoreCase false )
Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$needle
$haystack
$message
optional '' $ignoreCase
optional false assertTextEndsNotWith( string $suffix , string $string , string $message '' )
Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$suffix
$string
$message
optional '' assertTextEndsWith( string $suffix , string $string , string $message '' )
Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$suffix
$string
$message
optional '' assertTextEquals( string $expected , string $result , string $message '' )
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$expected
$result
$message
optional '' assertTextNotContains( string $needle , string $haystack , string $message '' , boolean $ignoreCase false )
Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$needle
$haystack
$message
optional '' $ignoreCase
optional false assertTextNotEquals( string $expected , string $result , string $message '' )
Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$expected
$result
$message
optional '' assertTextStartsNotWith( string $prefix , string $string , string $message '' )
Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$prefix
$string
$message
optional '' assertTextStartsWith( string $prefix , string $string , string $message '' )
Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.
$prefix
$string
$message
optional '' assertWithinRange( float $expected , float $result , float $margin , string $message '' )
Compatibility function to test if a value is between an acceptable range.
$expected
$result
$margin
$message
optional '' getMockForModel( string $alias , array $methods [] , array $options [] )
Mock a model, maintain fixtures and table association
$alias
$methods
optional [] $options
optional [] Cake\ORM\Table
|PHPUnit_Framework_MockObject_MockObjectCake\ORM\Exception\MissingTableClassException
loadFixtures( )
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.
setUp( )
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.
skipIf( boolean $shouldSkip , string $message '' )
Overrides SimpleTestCase::skipIf to provide a boolean return value
$shouldSkip
$message
optional '' skipUnless( boolean $condition , string $message '' )
Compatibility function for skipping.
$condition
$message
optional '' public boolean
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
true
public boolean
Control table create/drops on each test method.
If true, tables will still be dropped at the end of each test runner execution.
false
public Cake\TestSuite\Fixture\FixtureManager
|null
The class responsible for managing the creation, loading and removing of fixtures
null
© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.4/class-Cake.TestSuite.TestCase.html