Class UnitTestCase

Description

Standard unit test class for day to day testing of PHP code XP style. Adds some useful standard assertions.

Located in /unit_tester.php (line 23)

SimpleTestCase
   |
   --UnitTestCase
Direct descendents
Class Description
 class SeleneseTestCase SeleneseTestCase
 class SeleniumTestCase Standard unit test class for day to day testing of PHP code XP style. Adds some useful standard assertions.
Method Summary
 UnitTestCase UnitTestCase ([string $label = false])
 boolean assertClone ( &$first,  &$second, [string $message = '%s'], mixed $first, mixed $second)
 void assertCopy ( &$first,  &$second, [ $message = "%s"])
 boolean assertEqual (mixed $first, mixed $second, [string $message = '%s'])
 void assertError ([ $expected = false], [ $message = '%s'])
 void assertErrorPattern ( $pattern, [ $message = '%s'])
 boolean assertFalse (boolean $result, [string $message = '%s'])
 boolean assertIdentical (mixed $first, mixed $second, [string $message = '%s'])
 boolean assertIsA (mixed $object, string $type, [string $message = '%s'])
 void assertNoErrors ([ $message = '%s'])
 boolean assertNoPattern (string $pattern, string $subject, [string $message = '%s'])
 boolean assertNotA (mixed $object, string $type, [string $message = '%s'])
 boolean assertNotEqual (mixed $first, mixed $second, [string $message = '%s'])
 boolean assertNotIdentical (mixed $first, mixed $second, [string $message = '%s'])
 boolean assertNotNull (mixed $value, [string $message = '%s'])
 void assertNoUnwantedPattern ( $pattern,  $subject, [ $message = '%s'])
 boolean assertNull (null $value, [string $message = '%s'])
 boolean assertOutsideMargin (mixed $first, mixed $second, mixed $margin, [string $message = '%s'])
 boolean assertPattern (string $pattern, string $subject, [string $message = '%s'])
 boolean assertReference ( &$first,  &$second, [string $message = '%s'], mixed $first, mixed $second)
 boolean assertTrue (boolean $result, [string $message = false])
 void assertWantedPattern ( $pattern,  $subject, [ $message = '%s'])
 boolean assertWithinMargin (mixed $first, mixed $second, mixed $margin, [string $message = '%s'])
 void expectError ([SimpleExpectation/string $expected = false], [string $message = '%s'])
 void expectException ([SimpleExpectation/Exception $expected = false], [string $message = '%s'])
 void swallowErrors ()
Variables
Methods
Constructor UnitTestCase (line 32)

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

  • access: public
UnitTestCase UnitTestCase ([string $label = false])
  • string $label: Name of test case. Will use the class name if none specified.
assertClone (line 259)

Will trigger a pass if both parameters refer to different objects. Fail otherwise. The objects have to be identical though.

  • return: True on pass
  • access: public
boolean assertClone ( &$first,  &$second, [string $message = '%s'], mixed $first, mixed $second)
  • mixed $first: Object reference to check.
  • mixed $second: Hopefully not the same object.
  • string $message: Message to display.
  • &$first
  • &$second
assertCopy (line 276)
  • deprecated:
void assertCopy ( &$first,  &$second, [ $message = "%s"])
  • &$first
  • &$second
  • $message
assertEqual (line 139)

Will trigger a pass if the two parameters have the same value only. Otherwise a fail.

  • return: True on pass
  • access: public
boolean assertEqual (mixed $first, mixed $second, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertError (line 357)
  • deprecated:
void assertError ([ $expected = false], [ $message = '%s'])
  • $expected
  • $message
assertErrorPattern (line 416)
  • deprecated:
void assertErrorPattern ( $pattern, [ $message = '%s'])
  • $pattern
  • $message
assertFalse (line 62)

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.

  • return: True on pass
  • access: public
boolean assertFalse (boolean $result, [string $message = '%s'])
  • boolean $result: Pass on false.
  • string $message: Message to display.
assertIdentical (line 205)

Will trigger a pass if the two parameters have the same value and same type. Otherwise a fail.

  • return: True on pass
  • access: public
boolean assertIdentical (mixed $first, mixed $second, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertIsA (line 106)

Type and class test. Will pass if class matches the type name or is a subclass or if not an object, but the type is correct.

  • return: True on pass.
  • access: public
boolean assertIsA (mixed $object, string $type, [string $message = '%s'])
  • mixed $object: Object to test.
  • string $type: Type name as string.
  • string $message: Message to display.
assertNoErrors (line 348)
  • deprecated:
void assertNoErrors ([ $message = '%s'])
  • $message
assertNoPattern (line 322)

Will trigger a pass if the perl regex pattern is not present in subject. Fail if found.

  • return: True on pass
  • access: public
boolean assertNoPattern (string $pattern, string $subject, [string $message = '%s'])
  • string $pattern: Perl regex to look for including the regex delimiters.
  • string $subject: String to search in.
  • string $message: Message to display.
assertNotA (line 123)

Type and class mismatch test. Will pass if class name or underling type does not match the one specified.

  • return: True on pass.
  • access: public
boolean assertNotA (mixed $object, string $type, [string $message = '%s'])
  • mixed $object: Object to test.
  • string $type: Type name as string.
  • string $message: Message to display.
assertNotEqual (line 155)

Will trigger a pass if the two parameters have a different value. Otherwise a fail.

  • return: True on pass
  • access: public
boolean assertNotEqual (mixed $first, mixed $second, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertNotIdentical (line 221)

Will trigger a pass if the two parameters have the different value or different type.

  • return: True on pass
  • access: public
boolean assertNotIdentical (mixed $first, mixed $second, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • string $message: Message to display.
assertNotNull (line 88)

Will be true if the value is set.

  • return: True on pass.
  • access: public
boolean assertNotNull (mixed $value, [string $message = '%s'])
  • mixed $value: Supposedly set value.
  • string $message: Message to display.
assertNoUnwantedPattern (line 332)
  • deprecated:
void assertNoUnwantedPattern ( $pattern,  $subject, [ $message = '%s'])
  • $pattern
  • $subject
  • $message
assertNull (line 73)

Will be true if the value is null.

  • return: True on pass
  • access: public
boolean assertNull (null $value, [string $message = '%s'])
  • null $value: Supposedly null value.
  • string $message: Message to display.
assertOutsideMargin (line 189)

Will trigger a pass if the two parameters differ by more than the margin.

  • return: True on pass
  • access: public
boolean assertOutsideMargin (mixed $first, mixed $second, mixed $margin, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • mixed $margin: Fuzziness of match.
  • string $message: Message to display.
assertPattern (line 298)

Will trigger a pass if the Perl regex pattern is found in the subject. Fail otherwise.

  • return: True on pass
  • access: public
boolean assertPattern (string $pattern, string $subject, [string $message = '%s'])
  • string $pattern: Perl regex to look for including the regex delimiters.
  • string $subject: String to search in.
  • string $message: Message to display.
assertReference (line 237)

Will trigger a pass if both parameters refer to the same object. Fail otherwise.

  • return: True on pass
  • access: public
boolean assertReference ( &$first,  &$second, [string $message = '%s'], mixed $first, mixed $second)
  • mixed $first: Object reference to check.
  • mixed $second: Hopefully the same object.
  • string $message: Message to display.
  • &$first
  • &$second
assertTrue (line 48)

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

  • return: True on pass
  • access: public
boolean assertTrue (boolean $result, [string $message = false])
  • boolean $result: Pass on true.
  • string $message: Message to display describing the test state.
assertWantedPattern (line 308)
  • deprecated:
void assertWantedPattern ( $pattern,  $subject, [ $message = '%s'])
  • $pattern
  • $subject
  • $message
assertWithinMargin (line 172)

Will trigger a pass if the if the first parameter is near enough to the second by the margin.

  • return: True on pass
  • access: public
boolean assertWithinMargin (mixed $first, mixed $second, mixed $margin, [string $message = '%s'])
  • mixed $first: Value to compare.
  • mixed $second: Value to compare.
  • mixed $margin: Fuzziness of match.
  • string $message: Message to display.
expectError (line 371)

Prepares for an error. If the error mismatches it passes through, otherwise it is swallowed. Any left over errors trigger failures.

  • access: public
void expectError ([SimpleExpectation/string $expected = false], [string $message = '%s'])
  • SimpleExpectation/string $expected: The error to match.
  • string $message: Message on failure.
expectException (line 385)

Prepares for an exception. If the error mismatches it passes through, otherwise it is swallowed. Any left over errors trigger failures.

  • access: public
void expectException ([SimpleExpectation/Exception $expected = false], [string $message = '%s'])
  • SimpleExpectation/Exception $expected: The error to match.
  • string $message: Message on failure.
swallowErrors (line 339)
  • deprecated:
void swallowErrors ()

Inherited Methods

Inherited From SimpleTestCase

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

Documentation generated on Sun, 04 May 2008 09:22:21 -0500 by phpDocumentor 1.3.0