Class ShellTestCase

Description

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.

Located in /shell_tester.php (line 71)

SimpleTestCase
   |
   --ShellTestCase
Variable Summary
Method Summary
 ShellTestCase ShellTestCase ([string $label = false])
 boolean assertEqual (mixed $first, mixed $second, [string $message = "%s"])
 boolean assertExitCode (integer $status, [string $message = "%s"])
 boolean assertFalse (boolean $result, [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 assertNotEqual (mixed $first, mixed $second, [string $message = "%s"])
 boolean assertOutput (string $expected, [string $message = "%s"])
 boolean assertOutputPattern (string $pattern, [string $message = "%s"])
 boolean assertTrue (boolean $result, [string $message = false])
 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::$_observers
SimpleTestCase::$_reporter
SimpleTestCase::$_should_skip
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.
assertEqual (line 168)

Will trigger a pass if the two parameters have the same value only. Otherwise a fail. This is for testing hand extracted text, etc.

  • return: True on pass
  • access: public
boolean assertEqual (mixed $first, mixed $second, [string $message = "%s"])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertExitCode (line 200)

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.
assertFalse (line 154)

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 as false.

  • return: True on pass
  • access: public
boolean assertFalse (boolean $result, [string $message = '%s'])
  • boolean $result: Pass on false.
  • string $message: Message to display.
assertFileExists (line 262)

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 274)

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 288)

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 305)

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 247)

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.
assertNotEqual (line 185)

Will trigger a pass if the two parameters have a different value. Otherwise a fail. This is for testing hand extracted text, etc.

  • return: True on pass
  • access: public
boolean assertNotEqual (mixed $first, mixed $second, [string $message = "%s"])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertOutput (line 215)

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 231)

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.
assertTrue (line 140)

Called from within the test methods to register passes and failures.

  • return: True on pass
  • access: public
boolean assertTrue (boolean $result, [string $message = false])
  • boolean $result: Pass on true.
  • string $message: Message to display describing the test state.
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 328)

Factory for the shell to run the command on.

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

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

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

Inherited Methods

Inherited From SimpleTestCase

 SimpleTestCase::SimpleTestCase()
 SimpleTestCase::after()
 SimpleTestCase::assert()
 SimpleTestCase::assertExpectation()
 SimpleTestCase::before()
 SimpleTestCase::createInvoker()
 SimpleTestCase::dump()
 SimpleTestCase::error()
 SimpleTestCase::exception()
 SimpleTestCase::fail()
 SimpleTestCase::getAssertionLine()
 SimpleTestCase::getLabel()
 SimpleTestCase::getSize()
 SimpleTestCase::getTests()
 SimpleTestCase::pass()
 SimpleTestCase::run()
 SimpleTestCase::sendMessage()
 SimpleTestCase::setUp()
 SimpleTestCase::signal()
 SimpleTestCase::skip()
 SimpleTestCase::skipIf()
 SimpleTestCase::skipUnless()
 SimpleTestCase::tearDown()
 SimpleTestCase::tell()
 SimpleTestCase::_isTest()

Documentation generated on Sun, 04 May 2008 09:22:08 -0500 by phpDocumentor 1.3.0