SimpleTestCase Class Reference

Inheritance diagram for SimpleTestCase:
[legend]

List of all members.


Public Member Functions

 SimpleTestCase ($label=false)
 getLabel ()
 skip ()
 skipIf ($should_skip, $message= '%s')
 skipUnless ($shouldnt_skip, $message=false)
createInvoker ()
 run (&$reporter)
 getTests ()
 _isTest ($method)
 before ($method)
 setUp ()
 tearDown ()
 after ($method)
 tell (&$observer)
 pass ($message= 'Pass', $group= 'Other')
 fail ($message= 'Fail', $group= 'Other')
 error ($severity, $message, $file, $line)
 exception ($exception)
 signal ($type, &$payload)
 assert (&$expectation, $compare, $message= '%s', $group= 'Other')
 assertExpectation (&$expectation, $compare, $message= '%s', $group= 'Other')
 getAssertionLine ()
 sendMessage ($message)

Static Public Member Functions

 getSize ()

Public Attributes

 $_label = false
 $_reporter
 $_observers
 $_should_skip = false


Detailed Description

Basic test case. This is the smallest unit of a test suite. It searches for all methods that start with the the string "test" and runs them. Working test cases extend this class.

Definition at line 10 of file test_case.php.


Member Function Documentation

SimpleTestCase::SimpleTestCase ( label = false  ) 

Sets up the test with no display.

Parameters:
string $label If no test name is given then the class name is used. public

Definition at line 22 of file test_case.php.

Referenced by UnitTestCase::UnitTestCase().

SimpleTestCase::getLabel (  ) 

Accessor for the test name for subclasses.

Returns:
string Name of the test. public

Definition at line 33 of file test_case.php.

Referenced by run().

SimpleTestCase::skip (  ) 

This is a placeholder for skipping tests. In this method you place skipIf() and skipUnless() calls to set the skipping state. public

Definition at line 43 of file test_case.php.

Referenced by run().

SimpleTestCase::skipIf ( should_skip,
message = '%s' 
)

Will issue a message to the reporter and tell the test case to skip if the incoming flag is true.

Parameters:
string $should_skip Condition causing the tests to be skipped.
string $message Text of skip condition. public

Definition at line 52 of file test_case.php.

References getAssertionLine().

Referenced by skipUnless().

Here is the call graph for this function:

SimpleTestCase::skipUnless ( shouldnt_skip,
message = false 
)

Will issue a message to the reporter and tell the test case to skip if the incoming flag is false.

Parameters:
string $shouldnt_skip Condition causing the tests to be run.
string $message Text of skip condition. public

Definition at line 67 of file test_case.php.

References skipIf().

Here is the call graph for this function:

& SimpleTestCase::createInvoker (  ) 

Used to invoke the single tests.

Returns:
SimpleInvoker Individual test runner. public

Definition at line 76 of file test_case.php.

Referenced by run().

SimpleTestCase::run ( &$  reporter  ) 

Uses reflection to run every method within itself starting with the string "test" unless a method is specified.

Parameters:
SimpleReporter $reporter Current test reporter.
Returns:
boolean True if all tests passed. public

Reimplemented in DrupalWebTestCase.

Definition at line 92 of file test_case.php.

References createInvoker(), SimpleTest::getContext(), getLabel(), getTests(), and skip().

Here is the call graph for this function:

SimpleTestCase::getTests (  ) 

Gets a list of test names. Normally that will be all internal methods that start with the name "test". This method should be overridden if you want a different rule.

Returns:
array List of test names. public

Definition at line 129 of file test_case.php.

References _isTest().

Referenced by run().

Here is the call graph for this function:

SimpleTestCase::_isTest ( method  ) 

Tests to see if the method is a test that should be run. Currently any method that starts with 'test' is a candidate unless it is the constructor.

Parameters:
string $method Method name to try.
Returns:
boolean True if test method. protected

Definition at line 147 of file test_case.php.

Referenced by getTests().

SimpleTestCase::before ( method  ) 

Announces the start of the test.

Parameters:
string $method Test method just started. public

Definition at line 159 of file test_case.php.

SimpleTestCase::setUp (  ) 

Sets up unit test wide variables at the start of each test method. To be overridden in actual user test cases. public

Reimplemented in DrupalWebTestCase.

Definition at line 170 of file test_case.php.

SimpleTestCase::tearDown (  ) 

Clears the data set in the setUp() method call. To be overridden by the user in actual user test cases. public

Reimplemented in DrupalWebTestCase.

Definition at line 177 of file test_case.php.

SimpleTestCase::after ( method  ) 

Announces the end of the test. Includes private clean up.

Parameters:
string $method Test method just finished. public

Definition at line 184 of file test_case.php.

SimpleTestCase::tell ( &$  observer  ) 

Sets up an observer for the test end.

Parameters:
object $observer Must have atTestEnd() method. public

Definition at line 197 of file test_case.php.

SimpleTestCase::pass ( message = 'Pass',
group = 'Other' 
)

Deprecated:

Definition at line 204 of file test_case.php.

References getAssertionLine().

Referenced by assert(), DrupalWebTestCase::drupalModuleDisable(), and DrupalWebTestCase::drupalModuleEnable().

Here is the call graph for this function:

SimpleTestCase::fail ( message = 'Fail',
group = 'Other' 
)

Sends a fail event with a message.

Parameters:
string $message Message to send. public

Definition at line 217 of file test_case.php.

References getAssertionLine().

Referenced by assert(), DrupalWebTestCase::drupalPost(), and DrupalWebTestCase::parse().

Here is the call graph for this function:

SimpleTestCase::error ( severity,
message,
file,
line 
)

Formats a PHP error and dispatches it to the reporter.

Parameters:
integer $severity PHP error code.
string $message Text of error.
string $file File error occoured in.
integer $line Line number of error. public

Definition at line 234 of file test_case.php.

SimpleTestCase::exception ( exception  ) 

Formats an exception and dispatches it to the reporter.

Parameters:
Exception $exception Object thrown. public

Definition at line 247 of file test_case.php.

SimpleTestCase::signal ( type,
&$  payload 
)

Deprecated:

Definition at line 254 of file test_case.php.

References $type.

SimpleTestCase::assert ( &$  expectation,
compare,
message = '%s',
group = 'Other' 
)

Runs an expectation directly, for extending the tests with new expectation classes.

Parameters:
SimpleExpectation $expectation Expectation subclass.
mixed $compare Value to compare.
string $message Message to display.
Returns:
boolean True on pass public

Definition at line 270 of file test_case.php.

References fail(), and pass().

Referenced by assertExpectation(), and UnitTestCase::assertTrue().

Here is the call graph for this function:

SimpleTestCase::assertExpectation ( &$  expectation,
compare,
message = '%s',
group = 'Other' 
)

Deprecated:

Definition at line 282 of file test_case.php.

References assert().

Here is the call graph for this function:

SimpleTestCase::getAssertionLine (  ) 

Uses a stack trace to find the line of an assertion.

Returns:
string Line number of first assert* method embedded in format string. public

Definition at line 292 of file test_case.php.

Referenced by fail(), pass(), and skipIf().

SimpleTestCase::sendMessage ( message  ) 

Deprecated:

Definition at line 300 of file test_case.php.

SimpleTestCase::getSize (  )  [static]

Accessor for the number of subtests.

Returns:
integer Number of test cases. public

Definition at line 310 of file test_case.php.


Member Data Documentation

SimpleTestCase::$_label = false

Definition at line 11 of file test_case.php.

SimpleTestCase::$_reporter

Definition at line 12 of file test_case.php.

SimpleTestCase::$_observers

Definition at line 13 of file test_case.php.

SimpleTestCase::$_should_skip = false

Definition at line 14 of file test_case.php.


The documentation for this class was generated from the following file:

Generated on Mon Jun 2 15:09:15 2008 for SimpleTest by  1.5.5