PHP Class ShellTestCase, simpletest

Inheritance: extends SimpleTestCase
Afficher le fichier Open project: simpletest/simpletest Class Usage Examples

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
createShell ( ) : SimpleShell Factory for the shell to run the command on.
getShell ( ) : SimpleShell Accessor for current shell. Used for testing the the tester itself.

Method Details

__construct() public méthode

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() public méthode

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.
Résultat boolean True on pass, Otherwise a fail.

assertExitCode() public méthode

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.
Résultat boolean True if pass.

assertFalse() public méthode

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.
Résultat boolean True on pass

assertFileExists() public méthode

File existence check.
public assertFileExists ( string $path, string $message = '%s' ) : boolean
$path string Full filename and path.
$message string Message to display.
Résultat boolean True if pass.

assertFileNotExists() public méthode

File non-existence check.
public assertFileNotExists ( string $path, string $message = '%s' ) : boolean
$path string Full filename and path.
$message string Message to display.
Résultat boolean True if pass.

assertFilePattern() public méthode

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.
Résultat boolean True if pass.

assertNoFilePattern() public méthode

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.
Résultat boolean True if pass.

assertNoOutputPattern() public méthode

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.
Résultat boolean True if pass.

assertNotEqual() public méthode

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.
Résultat boolean True on pass, Otherwise a fail.

assertOutput() public méthode

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.
Résultat boolean True if pass.

assertOutputPattern() public méthode

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.
Résultat boolean True if pass.

assertTrue() public méthode

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.
Résultat boolean True on pass

createShell() protected méthode

Factory for the shell to run the command on.
protected createShell ( ) : SimpleShell
Résultat SimpleShell New shell object.

dumpOutput() public méthode

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

execute() public méthode

Executes a command and buffers the results.
public execute ( string $command ) : boolean
$command string Command to run.
Résultat boolean True if zero exit code.

getOutput() public méthode

Accessor for the last output.
public getOutput ( ) : string
Résultat string Output as text.

getOutputAsList() public méthode

Accessor for the last output.
public getOutputAsList ( ) : array
Résultat array Output as array of lines.

getShell() protected méthode

Accessor for current shell. Used for testing the the tester itself.
protected getShell ( ) : SimpleShell
Résultat SimpleShell Current shell.