Source for file shell_tester.php
Documentation is available at shell_tester.php
* base include file for SimpleTest
* @version $Id: shell_tester.php 1723 2008-04-08 00:34:10Z lastcraft $
* include other SimpleTest class files
require_once(dirname(__FILE__
) .
'/test_case.php');
* Wrapper for exec() functionality.
* Executes the shell comand and stashes the output.
* Actually runs the command. Does not trap the
* error stream output as this need PHP 4.3+.
* @param string $command The actual command line
* @return integer Exit code.
* Accessor for the last output.
* @return string Output as text.
* Accessor for the last output.
* @return array Output as array of lines.
* Test case for testing of command line scripts and
* utilities. Usually scripts that are external to the
* PHP code, but support it in some way.
* Creates an empty test case. Should be subclassed
* with test methods for a functional test case.
* @param string $label Name of test case. Will use
* the class name if none specified.
* Executes a command and buffers the results.
* @param string $command Command to run.
* @return boolean True if zero exit code.
* Dumps the output of the last command.
* Accessor for the last output.
* @return string Output as text.
return $shell->getOutput();
* Accessor for the last output.
* @return array Output as array of lines.
return $shell->getOutputAsList();
* Called from within the test methods to register
* @param boolean $result Pass on true.
* @param string $message Message to display describing
* @return boolean True on pass
* Will be true on false and vice versa. False
* is the PHP definition of false, so that null,
* empty strings, zero and an empty array all count
* @param boolean $result Pass on false.
* @param string $message Message to display.
* @return boolean True on pass
* Will trigger a pass if the two parameters have
* the same value only. Otherwise a fail. This
* is for testing hand extracted text, etc.
* @param mixed $first Value to compare.
* @param mixed $second Value to compare.
* @param string $message Message to display.
* @return boolean True on pass
function assertEqual($first, $second, $message =
"%s") {
* Will trigger a pass if the two parameters have
* a different value. Otherwise a fail. This
* is for testing hand extracted text, etc.
* @param mixed $first Value to compare.
* @param mixed $second Value to compare.
* @param string $message Message to display.
* @return boolean True on pass
* Tests the last status code from the shell.
* @param integer $status Expected status of last
* @param string $message Message to display.
* @return boolean True if pass.
$message =
sprintf($message, "Expected status code of [$status] from [" .
* Attempt to exactly match the combined STDERR and
* @param string $expected Expected output.
* @param string $message Message to display.
* @return boolean True if pass.
* Scans the output for a Perl regex. If found
* anywhere it passes, else it fails.
* @param string $pattern Regex to search for.
* @param string $message Message to display.
* @return boolean True if pass.
* If a Perl regex is found anywhere in the current
* output then a failure is generated, else a pass.
* @param string $pattern Regex to search for.
* @param $message Message to display.
* @return boolean True if pass.
* @param string $path Full filename and path.
* @param string $message Message to display.
* @return boolean True if pass.
$message =
sprintf($message, "File [$path] should exist");
* File non-existence check.
* @param string $path Full filename and path.
* @param string $message Message to display.
* @return boolean True if pass.
$message =
sprintf($message, "File [$path] should not exist");
* Scans a file for a Perl regex. If found
* anywhere it passes, else it fails.
* @param string $pattern Regex to search for.
* @param string $path Full filename and path.
* @param string $message Message to display.
* @return boolean True if pass.
* If a Perl regex is found anywhere in the named
* file then a failure is generated, else a pass.
* @param string $pattern Regex to search for.
* @param string $path Full filename and path.
* @param string $message Message to display.
* @return boolean True if pass.
* Accessor for current shell. Used for testing the
* @return Shell Current shell.
* Factory for the shell to run the command on.
* @return Shell New shell object.
Documentation generated on Sun, 04 May 2008 09:22:08 -0500 by phpDocumentor 1.3.0