[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/test_tools/simpletest/ -> simple_test.php (sommaire)

Base include file for SimpleTest

Version: $Id: simple_test.php 1526 2006-11-28 23:34:00Z wei $
Poids: 553 lignes (20 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 3 classes

SimpleTestCase:: (19 méthodes):
  SimpleTestCase()
  getLabel()
  createInvoker()
  _createRunner()
  run()
  setUp()
  tearDown()
  pass()
  fail()
  error()
  signal()
  swallowErrors()
  assertExpectation()
  assertTrue()
  assertFalse()
  getAssertionLine()
  dump()
  sendMessage()
  getSize()

GroupTest:: (13 méthodes):
  GroupTest()
  getLabel()
  addTestCase()
  addTestClass()
  addTestFile()
  _requireWithError()
  _enableErrorReporting()
  _disableErrorReporting()
  _selectRunnableTests()
  _createGroupFromClasses()
  _isTestCase()
  run()
  getSize()

BadGroupTest:: (4 méthodes):
  BadGroupTest()
  getLabel()
  run()
  getSize()


Classe: 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.

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

return: SimpleInvoker        Individual test runner.

_createRunner($reporter)   X-Ref
Can modify the incoming reporter so as to run
the tests differently. This version simply
passes it straight through.

param: SimpleReporter $reporter    Incoming observer.
return: SimpleReporter

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.

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.


pass($message = "Pass")   X-Ref
Sends a pass event with a message.

param: string $message        Message to send.

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

param: string $message        Message to send.

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

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.
param: hash $globals      PHP super global arrays.

signal($type, $payload)   X-Ref
Sends a user defined event to the test runner.
This is for small scale extension where
both the test case and either the runner or
display are subclassed.

param: string $type       Type of event.
param: mixed $payload     Object or message to deliver.

swallowErrors()   X-Ref
Cancels any outstanding errors.


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

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

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 = false)   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

getAssertionLine($format = '%d', $stack = false)   X-Ref
Uses a stack trace to find the line of an assertion.

param: string $format    String formatting.
param: array $stack      Stack frames top most first. Only
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
Dispatches a text message straight to the
test suite. Useful for status bar displays.

param: string $message        Message to show.

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

return: integer           Number of test cases.

Classe: GroupTest  - X-Ref

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

GroupTest($label)   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.

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: GroupTest          Group loaded with the new

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

param: string $class            Class name.

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.

Classe: BadGroupTest  - X-Ref

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

BadGroupTest($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.



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7