PHP Class ShellTestCase, simpletest

Inheritance: extends SimpleTestCase
Mostra file Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method 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.

Protected Methods

Method 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 method

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 method

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

assertExitCode() public method

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.
return boolean True if pass.

assertFalse() public method

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.
return boolean True on pass

assertFileExists() public method

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

assertFileNotExists() public method

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

assertFilePattern() public method

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.
return boolean True if pass.

assertNoFilePattern() public method

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.
return boolean True if pass.

assertNoOutputPattern() public method

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.
return boolean True if pass.

assertNotEqual() public method

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

assertOutput() public method

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.
return boolean True if pass.

assertOutputPattern() public method

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.
return boolean True if pass.

assertTrue() public method

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.
return boolean True on pass

createShell() protected method

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

dumpOutput() public method

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

execute() public method

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

getOutput() public method

Accessor for the last output.
public getOutput ( ) : string
return string Output as text.

getOutputAsList() public method

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

getShell() protected method

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