PHP Класс ShellTestCase, simpletest

Наследование: extends SimpleTestCase
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( string $label = false ) Creates an empty test case.
assertEqual ( mixed $first, mixed $second, string $message = '%s' ) : boolean Will trigger a pass if the two parameters have the same value only.
assertExitCode ( integer $status, string $message = '%s' ) : boolean Tests the last status code from the shell.
assertFalse ( boolean $result, string $message = '%s' ) : boolean Will be true on false and vice versa.
assertFileExists ( string $path, string $message = '%s' ) : boolean File existence check.
assertFileNotExists ( string $path, string $message = '%s' ) : boolean File non-existence check.
assertFilePattern ( string $pattern, string $path, string $message = '%s' ) : boolean Scans a file for a Perl regex. If found anywhere it passes, else it fails.
assertNoFilePattern ( string $pattern, string $path, string $message = '%s' ) : boolean If a Perl regex is found anywhere in the named file then a failure is generated, else a pass.
assertNoOutputPattern ( string $pattern, $message = '%s' ) : boolean If a Perl regex is found anywhere in the current output then a failure is generated, else a pass.
assertNotEqual ( mixed $first, mixed $second, string $message = '%s' ) : boolean Will trigger a pass if the two parameters have a different value.
assertOutput ( string $expected, string $message = '%s' ) : boolean Attempt to exactly match the combined STDERR and STDOUT output.
assertOutputPattern ( string $pattern, string $message = '%s' ) : boolean Scans the output for a Perl regex. If found anywhere it passes, else it fails.
assertTrue ( boolean $result, string $message = false ) : boolean Called from within the test methods to register passes and failures.
dumpOutput ( ) Dumps the output of the last command.
execute ( string $command ) : boolean Executes a command and buffers the results.
getOutput ( ) : string Accessor for the last output.
getOutputAsList ( ) : array Accessor for the last output.

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

Метод Описание
createShell ( ) : SimpleShell Factory for the shell to run the command on.
getShell ( ) : SimpleShell Accessor for current shell. Used for testing the the tester itself.

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

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

Should be subclassed with test methods for a functional test case.
public __construct ( string $label = false )
$label string Name of test case. Will use the class name if none specified.

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

This is for testing hand extracted text, etc.
public assertEqual ( mixed $first, mixed $second, string $message = '%s' ) : boolean
$first mixed Value to compare.
$second mixed Value to compare.
$message string Message to display.
Результат boolean True on pass, Otherwise a fail.

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

Tests the last status code from the shell.
public assertExitCode ( integer $status, string $message = '%s' ) : boolean
$status integer Expected status of last command.
$message string Message to display.
Результат boolean True if pass.

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

False is the PHP definition of false, so that null, empty strings, zero and an empty array all count as false.
public assertFalse ( boolean $result, string $message = '%s' ) : boolean
$result boolean Pass on false.
$message string Message to display.
Результат boolean True on pass

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

File existence check.
public assertFileExists ( string $path, string $message = '%s' ) : boolean
$path string Full filename and path.
$message string Message to display.
Результат boolean True if pass.

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

File non-existence check.
public assertFileNotExists ( string $path, string $message = '%s' ) : boolean
$path string Full filename and path.
$message string Message to display.
Результат boolean True if pass.

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

Scans a file for a Perl regex. If found anywhere it passes, else it fails.
public assertFilePattern ( string $pattern, string $path, string $message = '%s' ) : boolean
$pattern string Regex to search for.
$path string Full filename and path.
$message string Message to display.
Результат boolean True if pass.

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

If a Perl regex is found anywhere in the named file then a failure is generated, else a pass.
public assertNoFilePattern ( string $pattern, string $path, string $message = '%s' ) : boolean
$pattern string Regex to search for.
$path string Full filename and path.
$message string Message to display.
Результат boolean True if pass.

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

If a Perl regex is found anywhere in the current output then a failure is generated, else a pass.
public assertNoOutputPattern ( string $pattern, $message = '%s' ) : boolean
$pattern string Regex to search for.
$message Message to display.
Результат boolean True if pass.

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

This is for testing hand extracted text, etc.
public assertNotEqual ( mixed $first, mixed $second, string $message = '%s' ) : boolean
$first mixed Value to compare.
$second mixed Value to compare.
$message string Message to display.
Результат boolean True on pass, Otherwise a fail.

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

Attempt to exactly match the combined STDERR and STDOUT output.
public assertOutput ( string $expected, string $message = '%s' ) : boolean
$expected string Expected output.
$message string Message to display.
Результат boolean True if pass.

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

Scans the output for a Perl regex. If found anywhere it passes, else it fails.
public assertOutputPattern ( string $pattern, string $message = '%s' ) : boolean
$pattern string Regex to search for.
$message string Message to display.
Результат boolean True if pass.

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

Called from within the test methods to register passes and failures.
public assertTrue ( boolean $result, string $message = false ) : boolean
$result boolean Pass on true.
$message string Message to display describing the test state.
Результат boolean True on pass

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

Factory for the shell to run the command on.
protected createShell ( ) : SimpleShell
Результат SimpleShell New shell object.

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

Dumps the output of the last command.
public dumpOutput ( )

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

Executes a command and buffers the results.
public execute ( string $command ) : boolean
$command string Command to run.
Результат boolean True if zero exit code.

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

Accessor for the last output.
public getOutput ( ) : string
Результат string Output as text.

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

Accessor for the last output.
public getOutputAsList ( ) : array
Результат array Output as array of lines.

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

Accessor for current shell. Used for testing the the tester itself.
protected getShell ( ) : SimpleShell
Результат SimpleShell Current shell.