[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/lib/simpletestlib/ -> test_case.php (summary)

Base include file for SimpleTest

Version: $Id$
File Size: 679 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 5 classes

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

TestSuite:: (14 methods):
  TestSuite()
  getLabel()
  addTestCase()
  addTestClass()
  addTestFile()
  _requireWithError()
  _enableErrorReporting()
  _disableErrorReporting()
  _selectRunnableTests()
  _createGroupFromClasses()
  _getBaseTestCase()
  collect()
  run()
  getSize()

GroupTest:: (0 methods):

BadTestSuite:: (4 methods):
  BadTestSuite()
  getLabel()
  run()
  getSize()

BadGroupTest:: (0 methods):


Class: SimpleTestCase  - X-Ref

Basic test case. This is the smallest unit of a test
suite. It searches for
all methods that start with the the string "test" and
runs them. Working test cases extend this class.

SimpleTestCase($label = false)   X-Ref
Sets up the test with no display.

param: string $label    If no test name is given then

getLabel()   X-Ref
Accessor for the test name for subclasses.

return: string           Name of the test.

skip()   X-Ref
This is a placeholder for skipping tests. In this
method you place skipIf() and skipUnless() calls to
set the skipping state.


skipIf($should_skip, $message = '%s')   X-Ref
Will issue a message to the reporter and tell the test
case to skip if the incoming flag is true.

param: string $should_skip    Condition causing the tests to be skipped.
param: string $message        Text of skip condition.

skipUnless($shouldnt_skip, $message = false)   X-Ref
Will issue a message to the reporter and tell the test
case to skip if the incoming flag is false.

param: string $shouldnt_skip  Condition causing the tests to be run.
param: string $message        Text of skip condition.

createInvoker()   X-Ref
Used to invoke the single tests.

return: SimpleInvoker        Individual test runner.

run(&$reporter)   X-Ref
Uses reflection to run every method within itself
starting with the string "test" unless a method
is specified.

param: SimpleReporter $reporter    Current test reporter.
return: boolean                    True if all tests passed.

getTests()   X-Ref
Gets a list of test names. Normally that will
be all internal methods that start with the
name "test". This method should be overridden
if you want a different rule.

return: array        List of test names.

_isTest($method)   X-Ref
Tests to see if the method is a test that should
be run. Currently any method that starts with 'test'
is a candidate unless it is the constructor.

param: string $method        Method name to try.
return: boolean              True if test method.

before($method)   X-Ref
Announces the start of the test.

param: string $method    Test method just started.

setUp()   X-Ref
Sets up unit test wide variables at the start
of each test method. To be overridden in
actual user test cases.


tearDown()   X-Ref
Clears the data set in the setUp() method call.
To be overridden by the user in actual user test cases.


after($method)   X-Ref
Announces the end of the test. Includes private clean up.

param: string $method    Test method just finished.

tell(&$observer)   X-Ref
Sets up an observer for the test end.

param: object $observer    Must have atTestEnd()

pass($message = "Pass")   X-Ref


fail($message = "Fail")   X-Ref
Sends a fail event with a message.

param: string $message        Message to send.

error($severity, $message, $file, $line)   X-Ref
Formats a PHP error and dispatches it to the
reporter.

param: integer $severity  PHP error code.
param: string $message    Text of error.
param: string $file       File error occoured in.
param: integer $line      Line number of error.

exception($exception)   X-Ref
Formats an exception and dispatches it to the
reporter.

param: Exception $exception    Object thrown.

signal($type, &$payload)   X-Ref


assert(&$expectation, $compare, $message = '%s')   X-Ref
Runs an expectation directly, for extending the
tests with new expectation classes.

param: SimpleExpectation $expectation  Expectation subclass.
param: mixed $compare               Value to compare.
param: string $message                 Message to display.
return: boolean                        True on pass

assertExpectation(&$expectation, $compare, $message = '%s')   X-Ref


getAssertionLine()   X-Ref
Uses a stack trace to find the line of an assertion.

return: string           Line number of first assert*

dump($variable, $message = false)   X-Ref
Sends a formatted dump of a variable to the
test suite for those emergency debugging
situations.

param: mixed $variable    Variable to display.
param: string $message    Message to display.
return: mixed             The original variable.

sendMessage($message)   X-Ref


getSize()   X-Ref
Accessor for the number of subtests.

return: integer           Number of test cases.

Class: TestSuite  - X-Ref

This is a composite test class for combining
test cases and other RunnableTest classes into
a group test.

TestSuite($label = false)   X-Ref
Sets the name of the test suite.

param: string $label    Name sent at the start and end

getLabel()   X-Ref
Accessor for the test name for subclasses.

return: string           Name of the test.

addTestCase(&$test_case)   X-Ref
Adds a test into the suite. Can be either a group
test or some other unit test.

param: SimpleTestCase $test_case  Suite or individual test

addTestClass($class)   X-Ref
Adds a test into the suite by class name. The class will
be instantiated as needed.

param: SimpleTestCase $test_case  Suite or individual test

addTestFile($test_file)   X-Ref
Builds a group test from a library of test cases.
The new group is composed into this one.

param: string $test_file        File name of library with

_requireWithError($file)   X-Ref
Requires a source file recording any syntax errors.

param: string $file        File name to require in.
return: string/boolean     An error message on failure or false

_enableErrorReporting()   X-Ref
Sets up detection of parse errors. Note that XDebug
interferes with this and has to be disabled. This is
to make sure the correct error code is returned
from unattended scripts.


_disableErrorReporting()   X-Ref
Resets detection of parse errors to their old values.
This is to make sure the correct error code is returned
from unattended scripts.


_selectRunnableTests($existing_classes, $new_classes)   X-Ref
Calculates the incoming test cases from a before
and after list of loaded classes. Skips abstract
classes.

param: array $existing_classes   Classes before require().
param: array $new_classes        Classes after require().
return: array                    New classes which are test

_createGroupFromClasses($title, $classes)   X-Ref
Builds a group test from a class list.

param: string $title       Title of new group.
param: array $classes      Test classes.
return: TestSuite          Group loaded with the new

_getBaseTestCase($class)   X-Ref
Test to see if a class is derived from the
SimpleTestCase class.

param: string $class     Class name.

collect($path, &$collector)   X-Ref
Delegates to a visiting collector to add test
files.

param: string $path                  Path to scan from.
param: SimpleCollector $collector    Directory scanner.

run(&$reporter)   X-Ref
Invokes run() on all of the held test cases, instantiating
them if necessary.

param: SimpleReporter $reporter    Current test reporter.

getSize()   X-Ref
Number of contained test cases.

return: integer     Total count of cases in the group.

Class: GroupTest  - X-Ref


Class: BadTestSuite  - X-Ref

This is a failing group test for when a test suite hasn't
loaded properly.

BadTestSuite($label, $error)   X-Ref
Sets the name of the test suite and error message.

param: string $label    Name sent at the start and end

getLabel()   X-Ref
Accessor for the test name for subclasses.

return: string           Name of the test.

run(&$reporter)   X-Ref
Sends a single error to the reporter.

param: SimpleReporter $reporter    Current test reporter.

getSize()   X-Ref
Number of contained test cases. Always zero.

return: integer     Total count of cases in the group.

Class: BadGroupTest  - X-Ref




Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7