PHP Class SimpleTestCase, simpletest

@package SimpleTest
Afficher le fichier Open project: simpletest/simpletest Class Usage Examples

Protected Properties

Свойство Type Description
$reporter

Méthodes publiques

Méthode Description
__construct ( string $label = false ) Sets up the test with no display.
after ( string $method ) Announces the end of the test. Includes private clean up.
assert ( SimpleExpectation $expectation, mixed $compare, string $message = '%s' ) : boolean Runs an expectation directly, for extending the tests with new expectation classes.
before ( string $method ) Announces the start of the test.
createInvoker ( ) : SimpleInvoker Used to invoke the single tests.
dump ( mixed $variable, string $message = false ) : mixed Sends a formatted dump of a variable to the test suite for those emergency debugging situations.
error ( integer $severity, string $message, string $file, integer $line ) Formats a PHP error and dispatches it to the reporter.
exception ( Exception $exception ) Formats an exception and dispatches it to the reporter.
fail ( string $message = 'Fail' ) Sends a fail event with a message.
getAssertionLine ( ) : string Uses a stack trace to find the line of an assertion.
getLabel ( ) : string Accessor for the test name for subclasses.
getSize ( ) : integer Accessor for the number of subtests including myelf.
getTests ( ) : array 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.
pass ( $message = 'Pass' )
run ( SimpleReporter $reporter ) : boolean Uses reflection to run every method within itself starting with the string "test" unless a method is specified.
setUp ( ) Sets up unit test wide variables at the start of each test method.
shouldSkip ( ) Accessor for the private variable $_shoud_skip
signal ( string $type, mixed $payload ) For user defined expansion of the available messages.
skip ( ) This is a placeholder for skipping tests.
skipIf ( string $should_skip, string $message = '%s' ) Will issue a message to the reporter and tell the test case to skip if the incoming flag is true.
skipUnless ( string $shouldnt_skip, string $message = false ) Will issue a message to the reporter and tell the test case to skip if the incoming flag is false.
tearDown ( ) Clears the data set in the setUp() method call.
tell ( object $observer ) Sets up an observer for the test end.

Méthodes protégées

Méthode Description
escapePercentageSignsExceptFirst ( string $string ) : string Escapes all percentage signs, except the first.
isTest ( string $method ) : boolean Tests to see if the method is a test that should be run.

Method Details

__construct() public méthode

Sets up the test with no display.
public __construct ( string $label = false )
$label string If no test name is given then the class name is used.

after() public méthode

Announces the end of the test. Includes private clean up.
public after ( string $method )
$method string Test method just finished.

assert() public méthode

Runs an expectation directly, for extending the tests with new expectation classes.
public assert ( SimpleExpectation $expectation, mixed $compare, string $message = '%s' ) : boolean
$expectation SimpleExpectation Expectation subclass.
$compare mixed Value to compare.
$message string Message to display.
Résultat boolean True on pass

before() public méthode

Announces the start of the test.
public before ( string $method )
$method string Test method just started.

createInvoker() public méthode

Used to invoke the single tests.
public createInvoker ( ) : SimpleInvoker
Résultat SimpleInvoker Individual test runner.

dump() public méthode

Sends a formatted dump of a variable to the test suite for those emergency debugging situations.
public dump ( mixed $variable, string $message = false ) : mixed
$variable mixed Variable to display.
$message string Message to display. *
Résultat mixed The original variable.

error() public méthode

Formats a PHP error and dispatches it to the reporter.
public error ( integer $severity, string $message, string $file, integer $line )
$severity integer PHP error code.
$message string Text of error.
$file string File error occoured in.
$line integer Line number of error.

escapePercentageSignsExceptFirst() protected méthode

Get the position of the first percentage sign. Skip over escaping, if none is found. Else escape part of string after first percentage sign. Then concat unescaped first part and escaped part.
protected escapePercentageSignsExceptFirst ( string $string ) : string
$string string
Résultat string

exception() public méthode

Formats an exception and dispatches it to the reporter.
public exception ( Exception $exception )
$exception Exception Object thrown.

fail() public méthode

Sends a fail event with a message.
public fail ( string $message = 'Fail' )
$message string Message to send.

getAssertionLine() public méthode

Uses a stack trace to find the line of an assertion.
public getAssertionLine ( ) : string
Résultat string Line number of first assert method embedded in format string.

getLabel() public méthode

Accessor for the test name for subclasses.
public getLabel ( ) : string
Résultat string Name of the test.

getSize() public méthode

Accessor for the number of subtests including myelf.
public getSize ( ) : integer
Résultat integer Number of test cases.

getTests() public méthode

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.
public getTests ( ) : array
Résultat array List of test names.

isTest() protected méthode

Currently any method that starts with 'test' is a candidate unless it is the constructor.
protected isTest ( string $method ) : boolean
$method string Method name to try.
Résultat boolean True if test method.

pass() public méthode

Deprecation:
public pass ( $message = 'Pass' )

run() public méthode

Uses reflection to run every method within itself starting with the string "test" unless a method is specified.
public run ( SimpleReporter $reporter ) : boolean
$reporter SimpleReporter Current test reporter.
Résultat boolean True if all tests passed.

setUp() public méthode

To be overridden in actual user test cases.
public setUp ( )

shouldSkip() public méthode

Accessor for the private variable $_shoud_skip
public shouldSkip ( )

signal() public méthode

For user defined expansion of the available messages.
public signal ( string $type, mixed $payload )
$type string Tag for sorting the signals.
$payload mixed Extra user specific information.

skip() public méthode

In this method you place skipIf() and skipUnless() calls to set the skipping state.
public skip ( )

skipIf() public méthode

Will issue a message to the reporter and tell the test case to skip if the incoming flag is true.
public skipIf ( string $should_skip, string $message = '%s' )
$should_skip string Condition causing the tests to be skipped.
$message string Text of skip condition.

skipUnless() public méthode

Will issue a message to the reporter and tell the test case to skip if the incoming flag is false.
public skipUnless ( string $shouldnt_skip, string $message = false )
$shouldnt_skip string Condition causing the tests to be run.
$message string Text of skip condition.

tearDown() public méthode

To be overridden by the user in actual user test cases.
public tearDown ( )

tell() public méthode

Sets up an observer for the test end.
public tell ( object $observer )
$observer object Must have atTestEnd() method.

Property Details

$reporter protected_oe property

protected $reporter