Source for file phpunit_test_case.php

Documentation is available at phpunit_test_case.php

  1. <?php
  2.     /**
  3.      *    adapter for SimpleTest to use PHPUnit test cases
  4.      *    @package    SimpleTest
  5.      *    @subpackage Extensions
  6.      *    @version    $Id: phpunit_test_case.php 1530 2007-06-04 23:35:45Z lastcraft $
  7.      */
  8.     
  9.     /**#@+
  10.      * include SimpleTest files
  11.      */
  12.     require_once(dirname(__FILE__'/../unit_tester.php');
  13.     require_once(dirname(__FILE__'/../expectation.php');
  14.     /**#@-*/
  15.     
  16.          *    Adapter for sourceforge PHPUnit test case to allow
  17.      *    legacy test cases to be used with SimpleTest.
  18.      *    @package        SimpleTest
  19.      *    @subpackage    Extensions
  20.      */
  21.     class TestCase extends SimpleTestCase {
  22.         
  23.         /**
  24.          *    Constructor. Sets the test name.
  25.          *    @param $label        Test name to display.
  26.          *    @public
  27.          */
  28.         function TestCase($label false{
  29.             $this->SimpleTestCase($label);
  30.         }
  31.         
  32.         /**
  33.          *    Sends pass if the test condition resolves true,
  34.          *    a fail otherwise.
  35.          *    @param $condition      Condition to test true.
  36.          *    @param $message        Message to display.
  37.          *    @public
  38.          */
  39.         function assert($condition$message false{
  40.             parent::assert(new TrueExpectation()$condition$message);
  41.         }
  42.         
  43.         /**
  44.          *    Will test straight equality if set to loose
  45.          *    typing, or identity if not.
  46.          *    @param $first          First value.
  47.          *    @param $second         Comparison value.
  48.          *    @param $message        Message to display.
  49.          *    @public
  50.          */
  51.         function assertEquals($first$second$message false{
  52.             parent::assert(new EqualExpectation($first)$second$message);
  53.         }
  54.         
  55.         /**
  56.          *    Simple string equality.
  57.          *    @param $first          First value.
  58.          *    @param $second         Comparison value.
  59.          *    @param $message        Message to display.
  60.          *    @public
  61.          */
  62.         function assertEqualsMultilineStrings($first$second$message false{
  63.             parent::assert(new EqualExpectation($first)$second$message);
  64.         }                             
  65.         
  66.         /**
  67.          *    Tests a regex match.
  68.          *    @param $pattern        Regex to match.
  69.          *    @param $subject        String to search in.
  70.          *    @param $message        Message to display.
  71.          *    @public
  72.          */
  73.         function assertRegexp($pattern$subject$message false{
  74.             parent::assert(new PatternExpectation($pattern)$subject$message);
  75.         }
  76.         
  77.         /**
  78.          *    Sends an error which we interpret as a fail
  79.          *    with a different message for compatibility.
  80.          *    @param $message        Message to display.
  81.          *    @public
  82.          */
  83.         function error($message{
  84.             parent::fail("Error triggered [$message]");
  85.         }
  86.          
  87.         /**
  88.          *    Accessor for name.
  89.          *    @public
  90.          */
  91.        function name({
  92.             return $this->getLabel();
  93.         }
  94.     }
  95. ?>

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