Skip to content

Commit

Permalink
Extracting methods and features out into CakeBaseReporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 6, 2010
1 parent 5bd9734 commit 0d7875f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 39 deletions.
92 changes: 92 additions & 0 deletions cake/tests/lib/reporter/cake_base_reporter.php
@@ -0,0 +1,92 @@
<?php
/**
* CakeBaseReporter contains common functionality to all cake test suite reporters.
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.3
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/

/**
* CakeBaseReporter contains common reporting features used in the CakePHP Test suite
*
* @package cake
* @subpackage cake.tests.lib
*/
class CakeBaseReporter extends SimpleReporter {

/**
* Time the test runs started.
*
* @var integer
* @access protected
*/
var $_timeStart = 0;

/**
* Time the test runs ended
*
* @var integer
* @access protected
*/
var $_timeEnd = 0;

/**
* Duration of all test methods.
*
* @var integer
* @access protected
*/
var $_timeDuration = 0;

/**
* Signals / Paints the beginning of a TestSuite executing.
* Starts the timer for the TestSuite execution time.
*
* @param string $test_name Name of the test that is being run.
* @param integer $size
* @return void
*/
function paintGroupStart($test_name, $size) {
if (empty($this->_timeStart)) {
$this->_timeStart = $this->_getTime();
}
parent::paintGroupStart($test_name, $size);
}

/**
* Signals/Paints the end of a TestSuite. All test cases have run
* and timers are stopped.
*
* @param string $test_name Name of the test that is being run.
* @return void
*/
function paintGroupEnd($test_name) {
$this->_timeEnd = $this->_getTime();
$this->_timeDuration = $this->_timeEnd - $this->_timeStart;
parent::paintGroupEnd($test_name);
}

/**
* Get the current time in microseconds. Similar to getMicrotime in basics.php
* but in a separate function to reduce dependancies.
*
* @return float Time in microseconds
*/
function _getTime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$sec + (float)$usec);
}

}
40 changes: 1 addition & 39 deletions cake/tests/lib/reporter/cake_html_reporter.php
Expand Up @@ -18,6 +18,7 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/

include_once dirname(__FILE__) . DS . 'cake_base_reporter.php';
/**
* CakeHtmlReporter Reports Results of TestSuites and Test Cases
* in an HTML format / context.
Expand Down Expand Up @@ -80,45 +81,6 @@ function CakeHtmlReporter($character_set = 'ISO-8859-1') {
$this->_character_set = $character_set;
}

/**
* Signals / Paints the beginning of a TestSuite executing.
* Starts the timer for the TestSuite execution time.
*
* @param string $test_name Name of the test that is being run.
* @param integer $size
* @return void
*/
function paintGroupStart($test_name, $size) {
if (empty($this->_timeStart)) {
$this->_timeStart = $this->_getTime();
}
parent::paintGroupStart($test_name, $size);
}

/**
* Signals/Paints the end of a TestSuite. All test cases have run
* and timers are stopped.
*
* @param string $test_name Name of the test that is being run.
* @return void
*/
function paintGroupEnd($test_name) {
$this->_timeEnd = $this->_getTime();
$this->_timeDuration = $this->_timeEnd - $this->_timeStart;
parent::paintGroupEnd($test_name);
}

/**
* Get the current time in microseconds. Similar to getMicrotime in basics.php
* but in a separate function to reduce dependancies.
*
* @return float Time in microseconds
*/
function _getTime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$sec + (float)$usec);
}

/**
* Paints the top of the web page setting the
* title to the name of the starting test.
Expand Down

0 comments on commit 0d7875f

Please sign in to comment.