Class CakeTestCase
CakeTestCase class
- PHPUnit_Framework_TestCase
- 
			 CakeTestCase CakeTestCase
Direct Subclasses
Package: Cake\TestSuite
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/TestSuite/CakeTestCase.php
Properties summary
- 
			$_configureprotectedarrayConfigure values to restore at end of test.
- 
			$_pathRestoreprotectedarrayPath settings to restore at the end of the test.
- 
			$autoFixturespublicarrayBy default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually 
- 
			$dropTablespublicbooleanSet this to false to avoid tables to be dropped if they already exist
- 
			$fixtureManagerpublicThe class responsible for managing the creation, loading and removing of fixtures
Method Summary
- 
			_array_permute() protectedGenerates all permutation of an array $items and returns them in a new array.
- 
			assertEqual() protected staticCompatibility wrapper function for assertEquals
- 
			assertIdentical() protected staticCompatibility wrapper function for assertEquals
- 
			assertIsA() protected staticCompatibility wrapper for assertIsA
- 
			assertNoErrors() protected
- 
			assertNoPattern() protected staticCompatibility wrapper function for assertNotRegExp
- 
			assertNotEqual() protected staticCompatibility wrapper function for assertNotEquals
- 
			assertNotIdentical() protected staticCompatibility wrapper function for assertNotEquals
- 
			assertPattern() protected staticCompatibility wrapper function for assertRegexp
- 
			assertPostConditions() protectedAnnounces the end of a test.
- 
			assertPreConditions() protectedAnnounces the start of a test.
- 
			assertReference() protected staticCompatibility wrapper function for assertSame
- 
			assertTags() publicTakes an array $expected and generates a regex from it to match the provided $string. Samples for $expected: 
- 
			assertWithinMargin() protected staticCompatibility function to test if value is between an acceptable range
- 
			endTest() publicCalled when a test case method has been executed (to be overridden when needed.)
- 
			expectError() protectedCompatibility wrapper function for setExpectedException
- 
			expectException() protectedCompatibility wrapper function for setExpectedException
- 
			loadFixtures() publicChooses which fixtures to load for a given test
- 
			run() publicRuns the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created. This method is run for each test method in this class 
- 
			setUp() publicSetup 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() publicOverrides SimpleTestCase::skipIf to provide a boolean return value
- 
			skipUnless() protectedCompatibility function for skipping.
- 
			startTest() publicCalled when a test case method is about to start (to be overridden when needed.)
- 
			tearDown() publicteardown any static object changes and restore them.
Method Detail
_array_permute() protected ¶
_array_permute( array $items , $perms = array() )
Generates all permutation of an array $items and returns them in a new array.
Parameters
- array $items
- An array of items
- $perms optional array()
Returns
assertEqual() protected static ¶
assertEqual( mixed $result , mixed $expected , string $message = '' )
Compatibility wrapper function for assertEquals
Parameters
- mixed $result
- mixed $expected
- string $message optional ''
- the text to display if the assertion is not correct
assertIdentical() protected static ¶
assertIdentical( mixed $actual , mixed $expected , string $message = '' )
Compatibility wrapper function for assertEquals
Parameters
- mixed $actual
- mixed $expected
- string $message optional ''
- the text to display if the assertion is not correct
assertIsA() protected static ¶
assertIsA( string $object , string $type , string $message = '' )
Compatibility wrapper for assertIsA
Parameters
- string $object
- string $type
- string $message optional ''
assertNoPattern() protected static ¶
assertNoPattern( mixed $pattern , string $string , string $message = '' )
Compatibility wrapper function for assertNotRegExp
Parameters
- mixed $pattern
- a regular expression
- string $string
- the text to be matched
- string $message optional ''
- the text to display if the assertion is not correct
assertNotEqual() protected static ¶
assertNotEqual( mixed $result , mixed $expected , string $message = '' )
Compatibility wrapper function for assertNotEquals
Parameters
- mixed $result
- mixed $expected
- string $message optional ''
- the text to display if the assertion is not correct
assertNotIdentical() protected static ¶
assertNotIdentical( mixed $actual , mixed $expected , string $message = '' )
Compatibility wrapper function for assertNotEquals
Parameters
- mixed $actual
- mixed $expected
- string $message optional ''
- the text to display if the assertion is not correct
assertPattern() protected static ¶
assertPattern( mixed $pattern , string $string , string $message = '' )
Compatibility wrapper function for assertRegexp
Parameters
- mixed $pattern
- a regular expression
- string $string
- the text to be matched
- string $message optional ''
- the text to display if the assertion is not correct
assertPostConditions() protected ¶
assertPostConditions( string $method ,… )
Announces the end of a test.
Parameters
- string $method ,…
- Test method just finished.
assertPreConditions() protected ¶
assertPreConditions( string $method ,… )
Announces the start of a test.
Parameters
- string $method ,…
- Test method just started.
assertReference() protected static ¶
assertReference( mixed $first , mixed $second , string $message = '' )
Compatibility wrapper function for assertSame
Parameters
- mixed $first
- mixed $second
- string $message optional ''
- the text to display if the assertion is not correct
assertTags() public ¶
assertTags( string $string , array $expected , string $fullDebug = false )
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': array('input' => array('name', 'id' => 'my-input'))
Checks for two p elements with some text in them: array( array('p' => true), 'textA', '/p', array('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: array( array('input' => array('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.
Parameters
- string $string
- An HTML/XHTML/XML string
- array $expected
- An array, see above
- string $fullDebug optional false
- $message SimpleTest failure output string
Returns
assertWithinMargin() protected static ¶
assertWithinMargin( mixed $result , mixed $expected , mixed $margin , string $message = '' )
Compatibility function to test if value is between an acceptable range
Parameters
- mixed $result
- mixed $expected
- mixed $margin
- the rage of acceptation
- string $message optional ''
- the text to display if the assertion is not correct
endTest() public ¶
endTest( string $method )
Called when a test case method has been executed (to be overridden when needed.)
Parameters
- string $method
- Test method about that was executed.
expectError() protected ¶
expectError( mixed $expected = false , string $message = '' )
Compatibility wrapper function for setExpectedException
Parameters
- mixed $expected optional false
- the name of the Exception or error
- string $message optional ''
- the text to display if the assertion is not correct
expectException() protected ¶
expectException( mixed $name = 'Exception' , string $message = '' )
Compatibility wrapper function for setExpectedException
Parameters
- mixed $name optional 'Exception'
- $expected the name of the Exception
- string $message optional ''
- the text to display if the assertion is not correct
loadFixtures() public ¶
loadFixtures( string $fixture ,… )
Chooses which fixtures to load for a given test
Parameters
- string $fixture ,…
- Each parameter is a model name that corresponds to a fixture, i.e. 'Post', 'Author', etc. 
See
run() public ¶
run( PHPUnit_Framework_TestResult $result = NULL )
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created. This method is run for each test method in this class
Parameters
- PHPUnit_Framework_TestResult $result optional NULL
Returns
Throws
setUp() public ¶
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() public ¶
skipIf( boolean $shouldSkip , string $message = '' )
Overrides SimpleTestCase::skipIf to provide a boolean return value
Parameters
- boolean $shouldSkip
- string $message optional ''
Returns
skipUnless() protected ¶
skipUnless( boolean $condition , string $message = '' )
Compatibility function for skipping.
Parameters
- boolean $condition
- Condition to trigger skipping
- string $message optional ''
- Message for skip
Returns
startTest() public ¶
startTest( string $method )
Called when a test case method is about to start (to be overridden when needed.)
Parameters
- string $method
- Test method about to get executed.
Properties detail
$autoFixtures ¶
By default, all fixtures attached to this class will be truncated and reloaded after each test. Set this to false to handle manually
true
			$dropTables ¶
Set this to false to avoid tables to be dropped if they already exist
true
			$fixtureManager ¶
CakeFixtureManager
		The class responsible for managing the creation, loading and removing of fixtures
null
			