[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/tests_runner/lib/simpletest/ -> shell_tester.php (summary)

base include file for SimpleTest

Version: $Id: shell_tester.php 5999 2007-06-18 13:13:08Z pachanga $
File Size: 333 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

SimpleShell:: (4 methods):
  SimpleShell()
  execute()
  getOutput()
  getOutputAsList()

ShellTestCase:: (19 methods):
  ShellTestCase()
  execute()
  dumpOutput()
  getOutput()
  getOutputAsList()
  assertTrue()
  assertFalse()
  assertEqual()
  assertNotEqual()
  assertExitCode()
  assertOutput()
  assertOutputPattern()
  assertNoOutputPattern()
  assertFileExists()
  assertFileNotExists()
  assertFilePattern()
  assertNoFilePattern()
  _getShell()
  _createShell()


Class: SimpleShell  - X-Ref

Wrapper for exec() functionality.

SimpleShell()   X-Ref
Executes the shell comand and stashes the output.


execute($command)   X-Ref
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.

getOutput()   X-Ref
Accessor for the last output.

return: string        Output as text.

getOutputAsList()   X-Ref
Accessor for the last output.

return: array         Output as array of lines.

Class: ShellTestCase  - X-Ref

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.

ShellTestCase($label = false)   X-Ref
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

execute($command)   X-Ref
Executes a command and buffers the results.

param: string $command     Command to run.
return: boolean            True if zero exit code.

dumpOutput()   X-Ref
Dumps the output of the last command.


getOutput()   X-Ref
Accessor for the last output.

return: string        Output as text.

getOutputAsList()   X-Ref
Accessor for the last output.

return: array         Output as array of lines.

assertTrue($result, $message = false)   X-Ref
Called from within the test methods to register
passes and failures.

param: boolean $result    Pass on true.
param: string $message    Message to display describing
return: boolean           True on pass

assertFalse($result, $message = '%s')   X-Ref
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.

param: boolean $result    Pass on false.
param: string $message    Message to display.
return: boolean           True on pass

assertEqual($first, $second, $message = "%s")   X-Ref
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

assertNotEqual($first, $second, $message = "%s")   X-Ref
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

assertExitCode($status, $message = "%s")   X-Ref
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.

assertOutput($expected, $message = "%s")   X-Ref
Attempt to exactly match the combined STDERR and
STDOUT output.

param: string $expected  Expected output.
param: string $message   Message to display.
return: boolean          True if pass.

assertOutputPattern($pattern, $message = "%s")   X-Ref
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.

assertNoOutputPattern($pattern, $message = "%s")   X-Ref
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.

assertFileExists($path, $message = "%s")   X-Ref
File existence check.

param: string $path      Full filename and path.
param: string $message   Message to display.
return: boolean          True if pass.

assertFileNotExists($path, $message = "%s")   X-Ref
File non-existence check.

param: string $path      Full filename and path.
param: string $message   Message to display.
return: boolean          True if pass.

assertFilePattern($pattern, $path, $message = "%s")   X-Ref
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.

assertNoFilePattern($pattern, $path, $message = "%s")   X-Ref
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.

_getShell()   X-Ref
Accessor for current shell. Used for testing the
the tester itself.

return: Shell        Current shell.

_createShell()   X-Ref
Factory for the shell to run the command on.

return: Shell        New shell object.



Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7