PHPUnit
[ class tree: PHPUnit ] [ index: PHPUnit ] [ all elements ]

Source for file RepeatedTest.php

Documentation is available at RepeatedTest.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit                                                        |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  7. // +------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,        |
  9. // | that is available at http://www.php.net/license/3_0.txt.               |
  10. // | If you did not receive a copy of the PHP license and are unable to     |
  11. // | obtain it through the world-wide-web, please send a note to            |
  12. // | license@php.net so we can mail you a copy immediately.                 |
  13. // +------------------------------------------------------------------------+
  14. //
  15. // $Id: RepeatedTest.php,v 1.10 2004/12/22 08:06:11 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit/TestDecorator.php';
  19.  
  20. /**
  21.  * A Decorator that runs a test repeatedly.
  22.  *
  23.  * Here is an example:
  24.  *
  25.  * <code>
  26.  * <?php
  27.  * require_once 'PHPUnit.php';
  28.  * require_once 'PHPUnit/RepeatedTest.php';
  29.  *
  30.  * class MathTest extends PHPUnit_TestCase {
  31.  *     var $fValue1;
  32.  *     var $fValue2;
  33.  *
  34.  *     function MathTest($name) {
  35.  *         $this->PHPUnit_TestCase($name);
  36.  *     }
  37.  *
  38.  *     function setUp() {
  39.  *         $this->fValue1 = 2;
  40.  *         $this->fValue2 = 3;
  41.  *     }
  42.  *
  43.  *     function testAdd() {
  44.  *         $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
  45.  *     }
  46.  * }
  47.  *
  48.  * $suite = new PHPUnit_TestSuite;
  49.  *
  50.  * $suite->addTest(
  51.  *   new PHPUnit_RepeatedTest(
  52.  *     new MathTest('testAdd'),
  53.  *     10
  54.  *   )
  55.  * );
  56.  *
  57.  * $result = PHPUnit::run($suite);
  58.  * print $result->toString();
  59.  * ?>
  60.  * </code>
  61.  *
  62.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  63.  * @copyright   Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
  64.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  65.  * @category    Testing
  66.  * @package     PHPUnit
  67.  */
  68.     /**
  69.     * @var    integer 
  70.     * @access private
  71.     */
  72.     var $_timesRepeat = 1;
  73.  
  74.     /**
  75.     * Constructor.
  76.     *
  77.     * @param  object 
  78.     * @param  integer 
  79.     * @access public
  80.     */
  81.     function PHPUnit_RepeatedTest(&$test$timesRepeat = 1{
  82.         $this->PHPUnit_TestDecorator($test);
  83.         $this->_timesRepeat $timesRepeat;
  84.     }
  85.  
  86.     /**
  87.     * Counts the number of test cases that
  88.     * will be run by this test.
  89.     *
  90.     * @return integer 
  91.     * @access public
  92.     */
  93.     function countTestCases({
  94.         return $this->_timesRepeat $this->_test->countTestCases();
  95.     }
  96.  
  97.     /**
  98.     * Runs the decorated test and collects the
  99.     * result in a TestResult.
  100.     *
  101.     * @param  object 
  102.     * @access public
  103.     * @abstract
  104.     */
  105.     function run(&$result{
  106.         for ($i = 0; $i $this->_timesRepeat$i++{
  107.             $this->_test->run($result);
  108.         }
  109.     }
  110. }
  111. ?>

Documentation generated on Mon, 11 Mar 2019 14:22:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.