|
Moodle
2.2.1
http://www.collinsharper.com
|
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 | |
Definition at line 71 of file shell_tester.php.
| & _createShell | ( | ) |
Factory for the shell to run the command on.
Definition at line 328 of file shell_tester.php.

| & _getShell | ( | ) |
Accessor for current shell. Used for testing the the tester itself.
Definition at line 319 of file shell_tester.php.

| 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.
| mixed | $first | Value to compare. |
| mixed | $second | Value to compare. |
| string | $message | Message to display. |
Definition at line 168 of file shell_tester.php.
| assertExitCode | ( | $ | status, |
| $ | message = "%s" |
||
| ) |
Tests the last status code from the shell.
| integer | $status | Expected status of last command. |
| string | $message | Message to display. |
Definition at line 200 of file shell_tester.php.

| 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.
| boolean | $result | Pass on false. |
| string | $message | Message to display. |
Definition at line 154 of file shell_tester.php.

| assertFileExists | ( | $ | path, |
| $ | message = "%s" |
||
| ) |
File existence check.
| string | $path | Full filename and path. |
| string | $message | Message to display. |
Definition at line 262 of file shell_tester.php.

| assertFileNotExists | ( | $ | path, |
| $ | message = "%s" |
||
| ) |
File non-existence check.
| string | $path | Full filename and path. |
| string | $message | Message to display. |
Definition at line 274 of file shell_tester.php.

| assertFilePattern | ( | $ | pattern, |
| $ | path, | ||
| $ | message = "%s" |
||
| ) |
Scans a file for a Perl regex. If found anywhere it passes, else it fails.
| string | $pattern | Regex to search for. |
| string | $path | Full filename and path. |
| string | $message | Message to display. |
Definition at line 288 of file shell_tester.php.

| assertNoFilePattern | ( | $ | pattern, |
| $ | path, | ||
| $ | message = "%s" |
||
| ) |
If a Perl regex is found anywhere in the named file then a failure is generated, else a pass.
| string | $pattern | Regex to search for. |
| string | $path | Full filename and path. |
| string | $message | Message to display. |
Definition at line 305 of file shell_tester.php.

| assertNoOutputPattern | ( | $ | pattern, |
| $ | message = "%s" |
||
| ) |
If a Perl regex is found anywhere in the current output then a failure is generated, else a pass.
| string | $pattern | Regex to search for. |
| $message | Message to display. |
Definition at line 247 of file shell_tester.php.

| 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.
| mixed | $first | Value to compare. |
| mixed | $second | Value to compare. |
| string | $message | Message to display. |
Definition at line 185 of file shell_tester.php.
| assertOutput | ( | $ | expected, |
| $ | message = "%s" |
||
| ) |
Attempt to exactly match the combined STDERR and STDOUT output.
| string | $expected | Expected output. |
| string | $message | Message to display. |
Definition at line 215 of file shell_tester.php.

| assertOutputPattern | ( | $ | pattern, |
| $ | message = "%s" |
||
| ) |
Scans the output for a Perl regex. If found anywhere it passes, else it fails.
| string | $pattern | Regex to search for. |
| string | $message | Message to display. |
Definition at line 231 of file shell_tester.php.

| assertTrue | ( | $ | result, |
| $ | message = false |
||
| ) |
Called from within the test methods to register passes and failures.
| boolean | $result | Pass on true. |
| string | $message | Message to display describing the test state. |
Definition at line 140 of file shell_tester.php.

| dumpOutput | ( | ) |
Dumps the output of the last command. public
Definition at line 107 of file shell_tester.php.

| execute | ( | $ | command | ) |
Executes a command and buffers the results.
| string | $command | Command to run. |
Definition at line 96 of file shell_tester.php.

| getOutput | ( | ) |
Accessor for the last output.
Definition at line 116 of file shell_tester.php.


| getOutputAsList | ( | ) |
Accessor for the last output.
Definition at line 126 of file shell_tester.php.

| ShellTestCase | ( | $ | label = false | ) |
Creates an empty test case. Should be subclassed with test methods for a functional test case.
| string | $label | Name of test case. Will use the class name if none specified. public |
Definition at line 83 of file shell_tester.php.

| $_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.