PHP Класс SimpleTestCase, simpletest

@package SimpleTest
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$reporter

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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() публичный Метод

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

assert() публичный Метод

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.
Результат boolean True on pass

before() публичный Метод

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

createInvoker() публичный Метод

Used to invoke the single tests.
public createInvoker ( ) : SimpleInvoker
Результат SimpleInvoker Individual test runner.

dump() публичный Метод

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. *
Результат mixed The original variable.

error() публичный Метод

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() защищенный Метод

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
Результат string

exception() публичный Метод

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

fail() публичный Метод

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

getAssertionLine() публичный Метод

Uses a stack trace to find the line of an assertion.
public getAssertionLine ( ) : string
Результат string Line number of first assert method embedded in format string.

getLabel() публичный Метод

Accessor for the test name for subclasses.
public getLabel ( ) : string
Результат string Name of the test.

getSize() публичный Метод

Accessor for the number of subtests including myelf.
public getSize ( ) : integer
Результат integer Number of test cases.

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.
public getTests ( ) : array
Результат array List of test names.

isTest() защищенный Метод

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.
Результат boolean True if test method.

pass() публичный Метод

Устаревший:
public pass ( $message = 'Pass' )

run() публичный Метод

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.
Результат boolean True if all tests passed.

setUp() публичный Метод

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

shouldSkip() публичный Метод

Accessor for the private variable $_shoud_skip
public shouldSkip ( )

signal() публичный Метод

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() публичный Метод

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

skipIf() публичный Метод

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() публичный Метод

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() публичный Метод

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

tell() публичный Метод

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

Описание свойств

$reporter защищенное свойство

protected $reporter