SimpleTest


SimpleTest\ShellTestCase
shell_tester.php at line 71

Class ShellTestCase

SimpleTestCase
└─ShellTestCase

public class ShellTestCase
extends SimpleTestCase

Test case for testing of command line scripts and utilities. Usually scripts taht are external to the PHP code, but support it in some way.

Subpackage:
UnitTester
Package SimpleTest.
Subpackage UnitTester.

Constructor Summary

ShellTestCase(string label)

Creates an empty test case.

Method Summary
boolean

assertExitCode(integer status, string message)

Tests the last status code from the shell.

boolean

assertFileExists(string path, string message)

File existence check.

boolean

assertFileNotExists(string path, string message)

File non-existence check.

boolean

assertFilePattern(string pattern, string path, string message)

Scans a file for a Perl regex.

boolean

assertNoFilePattern(string pattern, string path, string message)

If a Perl regex is found anywhere in the named file then a failure is generated, else a pass.

boolean

assertNoOutputPattern(string pattern, mixed message, $message Message)

If a Perl regex is found anywhere in the current output then a failure is generated, else a pass.

boolean

assertOutput(string expected, string message)

Attempt to exactly match the combined STDERR and STDOUT output.

boolean

assertOutputPattern(string pattern, string message)

Scans the output for a Perl regex.

void

dumpOutput()

Dumps the output of the last command.

boolean

execute(string command)

Executes a command and buffers the results.

string

getOutput()

Accessor for the last output.

array

getOutputAsList()

Accessor for the last output.

Methods inherited from SimpleTest\SimpleTestCase
assertExpectation, assertFalse, assertTrue, createInvoker, dump, error, fail, getAssertionLine, getLabel, getSize, pass, run, sendMessage, setUp, signal, swallowErrors, tearDown

Constructor Detail

shell_tester.php at line 83

ShellTestCase

public ShellTestCase(string label)

Creates an empty test case. Should be subclassed with test methods for a functional test case.

Parameters:
label - Name of test case. Will use the class name if none specified.

Method Detail

shell_tester.php at line 139

assertExitCode

public boolean assertExitCode(integer status, string message)

Tests the last status code from the shell.

Parameters:
status - Expected status of last command.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 201

assertFileExists

public boolean assertFileExists(string path, string message)

File existence check.

Parameters:
path - Full filename and path.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 213

assertFileNotExists

public boolean assertFileNotExists(string path, string message)

File non-existence check.

Parameters:
path - Full filename and path.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 227

assertFilePattern

public boolean assertFilePattern(string pattern, string path, string message)

Scans a file for a Perl regex. If found anywhere it passes, else it fails.

Parameters:
pattern - Regex to search for.
path - Full filename and path.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 244

assertNoFilePattern

public boolean assertNoFilePattern(string pattern, string path, string message)

If a Perl regex is found anywhere in the named file then a failure is generated, else a pass.

Parameters:
pattern - Regex to search for.
path - Full filename and path.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 186

assertNoOutputPattern

public boolean assertNoOutputPattern(string pattern, mixed message, $message Message)

If a Perl regex is found anywhere in the current output then a failure is generated, else a pass.

Parameters:
pattern - Regex to search for.
Message - to display.
Returns:
True if pass.

shell_tester.php at line 154

assertOutput

public boolean assertOutput(string expected, string message)

Attempt to exactly match the combined STDERR and STDOUT output.

Parameters:
expected - Expected output.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 170

assertOutputPattern

public boolean assertOutputPattern(string pattern, string message)

Scans the output for a Perl regex. If found anywhere it passes, else it fails.

Parameters:
pattern - Regex to search for.
message - Message to display.
Returns:
True if pass.

shell_tester.php at line 107

dumpOutput

public void dumpOutput()

Dumps the output of the last command.


shell_tester.php at line 96

execute

public boolean execute(string command)

Executes a command and buffers the results.

Parameters:
command - Command to run.
Returns:
True if zero exit code.

shell_tester.php at line 116

getOutput

public string getOutput()

Accessor for the last output.

Returns:
Output as text.

shell_tester.php at line 126

getOutputAsList

public array getOutputAsList()

Accessor for the last output.

Returns:
Output as array of lines.

SimpleTest