Class ShellTestCase

Description

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.

Located in /libraries/pear/simpletest/shell_tester.php (line 71)

SimpleTestCase
   |
   --ShellTestCase
Direct descendents
Class Description
 class TestOfShellTesterAndShell 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.
 class TestOfShellTestCase 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.
 class TestOfVisualShell 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.
Variable Summary
Method Summary
 ShellTestCase ShellTestCase ([string $label = false])
 boolean assertExitCode (integer $status, [string $message = "%s"])
 boolean assertFileExists (string $path, [string $message = "%s"])
 boolean assertFileNotExists (string $path, [string $message = "%s"])
 boolean assertFilePattern (string $pattern, string $path, [string $message = "%s"])
 boolean assertNoFilePattern (string $pattern, string $path, [string $message = "%s"])
 boolean assertNoOutputPattern (string $pattern, [$message $message = "%s"])
 boolean assertOutput (string $expected, [string $message = "%s"])
 boolean assertOutputPattern (string $pattern, [string $message = "%s"])
 void dumpOutput ()
 boolean execute (string $command)
 string getOutput ()
 array getOutputAsList ()
 Shell &_createShell ()
 Shell &_getShell ()
Variables
mixed $_current_shell (line 72)
mixed $_last_command (line 74)
mixed $_last_status (line 73)

Inherited Variables

Inherited from SimpleTestCase

SimpleTestCase::$_label
SimpleTestCase::$_runner
Methods
Constructor ShellTestCase (line 83)

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

  • access: public
ShellTestCase ShellTestCase ([string $label = false])
  • string $label: Name of test case. Will use the class name if none specified.
assertExitCode (line 139)

Tests the last status code from the shell.

  • return: True if pass.
  • access: public
boolean assertExitCode (integer $status, [string $message = "%s"])
  • integer $status: Expected status of last command.
  • string $message: Message to display.
assertFileExists (line 201)

File existence check.

  • return: True if pass.
  • access: public
boolean assertFileExists (string $path, [string $message = "%s"])
  • string $path: Full filename and path.
  • string $message: Message to display.
assertFileNotExists (line 213)

File non-existence check.

  • return: True if pass.
  • access: public
boolean assertFileNotExists (string $path, [string $message = "%s"])
  • string $path: Full filename and path.
  • string $message: Message to display.
assertFilePattern (line 227)

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

  • return: True if pass.
  • access: public
boolean assertFilePattern (string $pattern, string $path, [string $message = "%s"])
  • string $pattern: Regex to search for.
  • string $path: Full filename and path.
  • string $message: Message to display.
assertNoFilePattern (line 244)

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

  • return: True if pass.
  • access: public
boolean assertNoFilePattern (string $pattern, string $path, [string $message = "%s"])
  • string $pattern: Regex to search for.
  • string $path: Full filename and path.
  • string $message: Message to display.
assertNoOutputPattern (line 186)

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

  • return: True if pass.
  • access: public
boolean assertNoOutputPattern (string $pattern, [$message $message = "%s"])
  • string $pattern: Regex to search for.
  • $message $message: Message to display.
assertOutput (line 154)

Attempt to exactly match the combined STDERR and STDOUT output.

  • return: True if pass.
  • access: public
boolean assertOutput (string $expected, [string $message = "%s"])
  • string $expected: Expected output.
  • string $message: Message to display.
assertOutputPattern (line 170)

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

  • return: True if pass.
  • access: public
boolean assertOutputPattern (string $pattern, [string $message = "%s"])
  • string $pattern: Regex to search for.
  • string $message: Message to display.
dumpOutput (line 107)

Dumps the output of the last command.

  • access: public
void dumpOutput ()
execute (line 96)

Executes a command and buffers the results.

  • return: True if zero exit code.
  • access: public
boolean execute (string $command)
  • string $command: Command to run.
getOutput (line 116)

Accessor for the last output.

  • return: Output as text.
  • access: public
string getOutput ()
getOutputAsList (line 126)

Accessor for the last output.

  • return: Output as array of lines.
  • access: public
array getOutputAsList ()
_createShell (line 267)

Factory for the shell to run the command on.

  • return: New shell object.
  • access: protected
Shell &_createShell ()
_getShell (line 258)

Accessor for current shell. Used for testing the the tester itself.

  • return: Current shell.
  • access: protected
Shell &_getShell ()

Redefined in descendants as:

Inherited Methods

Inherited From SimpleTestCase

 SimpleTestCase::SimpleTestCase()
 SimpleTestCase::after()
 SimpleTestCase::assertExpectation()
 SimpleTestCase::assertFalse()
 SimpleTestCase::assertTrue()
 SimpleTestCase::before()
 SimpleTestCase::dump()
 SimpleTestCase::error()
 SimpleTestCase::fail()
 SimpleTestCase::getAssertionLine()
 SimpleTestCase::getLabel()
 SimpleTestCase::getSize()
 SimpleTestCase::pass()
 SimpleTestCase::run()
 SimpleTestCase::sendMessage()
 SimpleTestCase::setUp()
 SimpleTestCase::signal()
 SimpleTestCase::swallowErrors()
 SimpleTestCase::tearDown()
 SimpleTestCase::_createRunner()

Documentation generated on Fri, 11 Feb 2005 18:13:59 +0000 by phpDocumentor 1.3.0RC3