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

Source for file RepeatedTest.php

Documentation is available at RepeatedTest.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit2                                                       |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2004 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.5 2004/05/26 06:24:04 sebastian Exp $
  16. //
  17.  
  18. require_once 'PHPUnit2/Framework/Test.php';
  19. require_once 'PHPUnit2/Framework/TestResult.php';
  20. require_once 'PHPUnit2/Extensions/TestDecorator.php';
  21.  
  22. /**
  23.  * A Decorator that runs a test repeatedly.
  24.  *
  25.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  26.  * @copyright   Copyright &copy; 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  27.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  28.  * @category    PHP
  29.  * @package     PHPUnit2
  30.  * @subpackage  Extensions
  31.  */
  32.     // {{{ Members
  33.  
  34.     /**
  35.     * @var    integer 
  36.     * @access private
  37.     */
  38.     private $timesRepeat = 1;
  39.  
  40.     // }}}
  41.     // {{{ public function __construct(PHPUnit2_Framework_Test $test, $timesRepeat = 1)
  42.  
  43.     /**
  44.     * Constructor.
  45.     *
  46.     * @param  PHPUnit2_Framework_Test $test 
  47.     * @param  integer                 $timesRepeat 
  48.     * @access public
  49.     */
  50.     public function __construct(PHPUnit2_Framework_Test $test$timesRepeat = 1{
  51.         parent::__construct($test);
  52.  
  53.         if (is_integer($timesRepeat&&
  54.             $timesRepeat >= 0{
  55.             $this->timesRepeat $timesRepeat;
  56.         else {
  57.             throw new Exception('Illegal argument.');
  58.         }
  59.     }
  60.  
  61.     // }}}
  62.     // {{{ public function countTestCases()
  63.  
  64.     /**
  65.     * Counts the number of test cases that
  66.     * will be run by this test.
  67.     *
  68.     * @return integer 
  69.     * @access public
  70.     */
  71.     public function countTestCases({
  72.         return $this->timesRepeat $this->test->countTestCases();
  73.     }
  74.  
  75.     // }}}
  76.     // {{{ public function run($result = null)
  77.  
  78.     /**
  79.     * Runs the decorated test and collects the
  80.     * result in a TestResult.
  81.     *
  82.     * @param  PHPUnit2_Framework_TestResult $result 
  83.     * @return PHPUnit2_Framework_TestResult 
  84.     * @access public
  85.     */
  86.     public function run($result = null{
  87.         if ($result === null{
  88.             $result $this->createResult();
  89.         }
  90.  
  91.         // XXX: Workaround for missing optional class type hints.
  92.         else if (!($result instanceof PHPUnit2_Framework_TestResult)) {
  93.             throw new Exception(
  94.               'Argument 1 must be an instance of PHPUnit2_Framework_TestResult.'
  95.             );
  96.         }
  97.  
  98.         for ($i = 0; $i $this->timesRepeat && !$result->shouldStop()$i++{
  99.             $this->test->run($result);
  100.         }
  101.  
  102.         return $result;
  103.     }
  104.  
  105.     // }}}
  106. }
  107.  
  108. /*
  109.  * vim600:  et sw=2 ts=2 fdm=marker
  110.  * vim<600: et sw=2 ts=2
  111.  */
  112. ?>

Documentation generated on Mon, 11 Mar 2019 13:55:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.