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
Method Summary
 ShellTestCase __construct ([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])
 Shell createShell ()
 void dumpOutput ()
 boolean execute (string $command)
 string getOutput ()
 array getOutputAsList ()
 Shell getShell ()
Variables

Inherited Variables

Inherited from SimpleTestCase

SimpleTestCase::$reporter
Methods
Constructor __construct (line 83)

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

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

Redefinition of:
SimpleTestCase::__construct()
Sets up the test with no display.
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 304)

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.
createShell (line 326)

Factory for the shell to run the command on.

  • return: New shell object.
  • access: protected
Shell createShell ()
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 ()
getShell (line 317)

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

  • return: Current shell.
  • access: protected
Shell getShell ()

Inherited Methods

Inherited From SimpleTestCase

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

Documentation generated on Sun, 31 Oct 2010 16:32:23 -0500 by phpDocumentor 1.4.3