Class SimpleTestCase

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.

Located in /test_case.php (line 38)


	
			
Direct descendents
Class Description
 class ShellTestCase Test case for testing of command line scripts and utilities. Usually scripts that are external to the PHP code, but support it in some way.
 class PHPUnit_TestCase Adapter for PEAR PHPUnit test case to allow legacy PEAR test cases to be used with SimpleTest.
 class UnitTestCase Standard unit test class for day to day testing of PHP code XP style. Adds some useful standard assertions.
 class WebTestCase Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
Variable Summary
 mixed $reporter
Method Summary
 SimpleTestCase __construct ([string $label = false])
 void after (string $method)
 boolean assert (SimpleExpectation $expectation, mixed $compare, [string $message = '%s'])
 void before (string $method)
 mixed dump (mixed $variable, [string $message = false])
 void error (integer $severity, string $message, string $file, integer $line)
 void exception (Exception $exception)
 void fail ([string $message = "Fail"])
 string getAssertionLine ()
 string getLabel ()
 integer getSize ()
 array getTests ()
 boolean isTest (string $method)
 void pass ([ $message = "Pass"])
 boolean run (SimpleReporter $reporter)
 void setUp ()
 void shouldSkip ()
 void signal (string $type, mixed $payload)
 void skip ()
 void skipIf (string $should_skip, [string $message = '%s'])
 void skipUnless (string $shouldnt_skip, [string $message = false])
 void tearDown ()
 void tell (object $observer)
Variables
mixed $reporter (line 40)
  • access: protected
Methods
Constructor __construct (line 50)

Sets up the test with no display.

  • access: public
SimpleTestCase __construct ([string $label = false])
  • string $label: If no test name is given then the class name is used.

Redefined in descendants as:
after (line 220)

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

  • access: public
void after (string $method)
  • string $method: Test method just finished.

Redefined in descendants as:
assert (line 311)

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

  • return: True on pass
  • access: public
boolean assert (SimpleExpectation $expectation, mixed $compare, [string $message = '%s'])
  • SimpleExpectation $expectation: Expectation subclass.
  • mixed $compare: Value to compare.
  • string $message: Message to display.
before (line 193)

Announces the start of the test.

  • access: public
void before (string $method)
  • string $method: Test method just started.

Redefined in descendants as:
createInvoker (line 113)

Used to invoke the single tests.

  • return: Individual test runner.
  • access: public
SimpleInvoker createInvoker ()
dump (line 343)

Sends a formatted dump of a variable to the test suite for those emergency debugging situations.

  • return: The original variable.
  • access: public
mixed dump (mixed $variable, [string $message = false])
  • mixed $variable: Variable to display.
  • string $message: Message to display.
error (line 272)

Formats a PHP error and dispatches it to the reporter.

  • access: public
void error (integer $severity, string $message, string $file, integer $line)
  • integer $severity: PHP error code.
  • string $message: Text of error.
  • string $file: File error occoured in.
  • integer $line: Line number of error.
exception (line 286)

Formats an exception and dispatches it to the reporter.

  • access: public
void exception (Exception $exception)
  • Exception $exception: Object thrown.
fail (line 254)

Sends a fail event with a message.

  • access: public
void fail ([string $message = "Fail"])
  • string $message: Message to send.
getAssertionLine (line 329)

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

  • return: Line number of first assert* method embedded in format string.
  • access: public
string getAssertionLine ()

Redefined in descendants as:
getLabel (line 61)

Accessor for the test name for subclasses.

  • return: Name of the test.
  • access: public
string getLabel ()
getSize (line 358)

Accessor for the number of subtests including myelf.

  • return: Number of test cases.
  • access: public
integer getSize ()
getTests (line 163)

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.

  • return: List of test names.
  • access: public
array getTests ()
isTest (line 181)

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.

  • return: True if test method.
  • access: protected
boolean isTest (string $method)
  • string $method: Method name to try.
pass (line 240)
  • deprecated:
void pass ([ $message = "Pass"])
  • $message
run (line 126)

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

  • return: True if all tests passed.
  • access: public
boolean run (SimpleReporter $reporter)
setUp (line 204)

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

  • access: public
void setUp ()

Redefined in descendants as:
shouldSkip (line 93)

Accessor for the private variable $_shoud_skip

  • access: public
void shouldSkip ()
signal (line 295)

For user defined expansion of the available messages.

void signal (string $type, mixed $payload)
  • string $type: Tag for sorting the signals.
  • mixed $payload: Extra user specific information.
skip (line 71)

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

  • access: public
void skip ()
skipIf (line 81)

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

  • access: public
void skipIf (string $should_skip, [string $message = '%s'])
  • string $should_skip: Condition causing the tests to be skipped.
  • string $message: Text of skip condition.
skipUnless (line 104)

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

  • access: public
void skipUnless (string $shouldnt_skip, [string $message = false])
  • string $shouldnt_skip: Condition causing the tests to be run.
  • string $message: Text of skip condition.
tearDown (line 212)

Clears the data set in the setUp() method call.

To be overridden by the user in actual user test cases.

  • access: public
void tearDown ()

Redefined in descendants as:
tell (line 233)

Sets up an observer for the test end.

  • access: public
void tell (object $observer)
  • object $observer: Must have atTestEnd() method.

Documentation generated on Sun, 31 Oct 2010 16:32:45 -0500 by phpDocumentor 1.4.3