Moodle  2.2.1
http://www.collinsharper.com
ShellTestCase Class Reference

Public Member Functions

 ShellTestCase ($label=false)
 execute ($command)
 dumpOutput ()
 getOutput ()
 getOutputAsList ()
 assertTrue ($result, $message=false)
 assertFalse ($result, $message= '%s')
 assertEqual ($first, $second, $message="%s")
 assertNotEqual ($first, $second, $message="%s")
 assertExitCode ($status, $message="%s")
 assertOutput ($expected, $message="%s")
 assertOutputPattern ($pattern, $message="%s")
 assertNoOutputPattern ($pattern, $message="%s")
 assertFileExists ($path, $message="%s")
 assertFileNotExists ($path, $message="%s")
 assertFilePattern ($pattern, $path, $message="%s")
 assertNoFilePattern ($pattern, $path, $message="%s")
_getShell ()
_createShell ()

Data Fields

 $_current_shell
 $_last_status
 $_last_command

Detailed Description

Definition at line 71 of file shell_tester.php.


Member Function Documentation

& _createShell ( )

Factory for the shell to run the command on.

Returns:
Shell New shell object. protected

Definition at line 328 of file shell_tester.php.

Here is the caller graph for this function:

& _getShell ( )

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

Returns:
Shell Current shell. protected

Definition at line 319 of file shell_tester.php.

Here is the caller graph for this function:

assertEqual ( first,
second,
message = "%s" 
)

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

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 168 of file shell_tester.php.

assertExitCode ( status,
message = "%s" 
)

Tests the last status code from the shell.

Parameters:
integer$statusExpected status of last command.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 200 of file shell_tester.php.

Here is the call graph for this function:

assertFalse ( result,
message = '%s' 
)

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.

Parameters:
boolean$resultPass on false.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 154 of file shell_tester.php.

Here is the caller graph for this function:

assertFileExists ( path,
message = "%s" 
)

File existence check.

Parameters:
string$pathFull filename and path.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 262 of file shell_tester.php.

Here is the call graph for this function:

assertFileNotExists ( path,
message = "%s" 
)

File non-existence check.

Parameters:
string$pathFull filename and path.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 274 of file shell_tester.php.

Here is the call graph for this function:

assertFilePattern ( pattern,
path,
message = "%s" 
)

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

Parameters:
string$patternRegex to search for.
string$pathFull filename and path.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 288 of file shell_tester.php.

Here is the call graph for this function:

assertNoFilePattern ( pattern,
path,
message = "%s" 
)

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

Parameters:
string$patternRegex to search for.
string$pathFull filename and path.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 305 of file shell_tester.php.

Here is the call graph for this function:

assertNoOutputPattern ( pattern,
message = "%s" 
)

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

Parameters:
string$patternRegex to search for.
$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 247 of file shell_tester.php.

Here is the call graph for this function:

assertNotEqual ( 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.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 185 of file shell_tester.php.

assertOutput ( expected,
message = "%s" 
)

Attempt to exactly match the combined STDERR and STDOUT output.

Parameters:
string$expectedExpected output.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 215 of file shell_tester.php.

Here is the call graph for this function:

assertOutputPattern ( pattern,
message = "%s" 
)

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

Parameters:
string$patternRegex to search for.
string$messageMessage to display.
Returns:
boolean True if pass. public

Definition at line 231 of file shell_tester.php.

Here is the call graph for this function:

assertTrue ( result,
message = false 
)

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

Parameters:
boolean$resultPass on true.
string$messageMessage to display describing the test state.
Returns:
boolean True on pass public

Definition at line 140 of file shell_tester.php.

Here is the caller graph for this function:

Dumps the output of the last command. public

Definition at line 107 of file shell_tester.php.

Here is the call graph for this function:

execute ( command)

Executes a command and buffers the results.

Parameters:
string$commandCommand to run.
Returns:
boolean True if zero exit code. public

Definition at line 96 of file shell_tester.php.

Here is the call graph for this function:

getOutput ( )

Accessor for the last output.

Returns:
string Output as text. public

Definition at line 116 of file shell_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Accessor for the last output.

Returns:
array Output as array of lines. public

Definition at line 126 of file shell_tester.php.

Here is the call graph for this function:

ShellTestCase ( label = false)

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

Parameters:
string$labelName of test case. Will use the class name if none specified. public

Definition at line 83 of file shell_tester.php.

Here is the call graph for this function:


Field Documentation

$_current_shell

Definition at line 72 of file shell_tester.php.

$_last_command

Definition at line 74 of file shell_tester.php.

$_last_status

Definition at line 73 of file shell_tester.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations