Permalink
Browse files

Extracting methods and features out into CakeBaseReporter.

  • Loading branch information...
1 parent 5bd9734 commit 0d7875f4ad35bee13d4427cb49faaf1b33c4e619 @markstory markstory committed Jan 6, 2010
Showing with 93 additions and 39 deletions.
  1. +92 −0 cake/tests/lib/reporter/cake_base_reporter.php
  2. +1 −39 cake/tests/lib/reporter/cake_html_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);
+ }
+
+}
@@ -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.
@@ -81,45 +82,6 @@ function CakeHtmlReporter($character_set = 'ISO-8859-1') {
}
/**
- * 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.
*

0 comments on commit 0d7875f

Please sign in to comment.