2010-01-06 01:29:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* CakeBaseReporter contains common functionality to all cake test suite reporters.
|
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* PHP 5
|
2010-01-06 01:29:08 +00:00
|
|
|
*
|
2010-05-19 01:15:13 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-01-06 01:29:08 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice
|
2010-01-06 01:29:08 +00:00
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-01-26 22:03:03 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.TestSuite.Reporter
|
2010-01-06 01:29:08 +00:00
|
|
|
* @since CakePHP(tm) v 1.3
|
2010-10-03 16:27:27 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2010-01-06 01:29:08 +00:00
|
|
|
*/
|
2011-02-21 19:51:26 +00:00
|
|
|
require_once 'PHPUnit/TextUI/ResultPrinter.php';
|
2010-01-06 01:29:08 +00:00
|
|
|
|
2010-09-28 03:07:23 +00:00
|
|
|
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
2010-05-08 20:18:45 +00:00
|
|
|
|
2010-01-06 01:29:08 +00:00
|
|
|
/**
|
|
|
|
* CakeBaseReporter contains common reporting features used in the CakePHP Test suite
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.TestSuite.Reporter
|
|
|
|
* @package Cake.TestSuite.Reporter
|
2010-01-06 01:29:08 +00:00
|
|
|
*/
|
2011-02-12 23:39:25 +00:00
|
|
|
class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
2010-01-06 01:29:08 +00:00
|
|
|
|
2011-02-13 04:07:39 +00:00
|
|
|
protected $_headerSent = false;
|
2010-01-06 01:29:08 +00:00
|
|
|
|
2010-01-09 16:20:47 +00:00
|
|
|
/**
|
|
|
|
* Array of request parameters. Usually parsed GET params.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $params = array();
|
2010-01-09 16:20:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Character set for the output of test reporting.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access protected
|
|
|
|
*/
|
2010-04-04 06:36:12 +00:00
|
|
|
protected $_characterSet;
|
2010-01-09 16:20:47 +00:00
|
|
|
|
2010-05-04 21:01:03 +00:00
|
|
|
/**
|
|
|
|
* The number of assertions done for a test suite
|
|
|
|
*/
|
|
|
|
protected $numAssertions = 0;
|
2011-02-13 04:07:39 +00:00
|
|
|
|
2010-01-09 16:20:47 +00:00
|
|
|
/**
|
|
|
|
* Does nothing yet. The first output will
|
|
|
|
* be sent on the first test start.
|
|
|
|
*
|
|
|
|
* ### Params
|
|
|
|
*
|
|
|
|
* - show_passes - Should passes be shown
|
|
|
|
* - plugin - Plugin test being run?
|
|
|
|
* - app - App test being run.
|
|
|
|
* - case - The case being run
|
2010-01-10 18:24:41 +00:00
|
|
|
* - codeCoverage - Whether the case/group being run is being code covered.
|
2011-02-21 19:51:26 +00:00
|
|
|
*
|
2010-01-09 16:20:47 +00:00
|
|
|
* @param string $charset The character set to output with. Defaults to UTF-8
|
|
|
|
* @param array $params Array of request parameters the reporter should use. See above.
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
function __construct($charset = 'utf-8', $params = array()) {
|
2010-01-10 17:48:11 +00:00
|
|
|
if (!$charset) {
|
|
|
|
$charset = 'utf-8';
|
|
|
|
}
|
2010-01-09 16:20:47 +00:00
|
|
|
$this->_characterSet = $charset;
|
|
|
|
$this->params = $params;
|
|
|
|
}
|
|
|
|
|
2010-01-06 03:52:25 +00:00
|
|
|
/**
|
|
|
|
* Retrieves a list of test cases from the active Manager class,
|
|
|
|
* displaying it in the correct format for the reporter subclass
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
public function testCaseList() {
|
2011-02-13 03:49:15 +00:00
|
|
|
$testList = CakeTestLoader::generateTestList($this->params);
|
2010-01-09 15:55:58 +00:00
|
|
|
return $testList;
|
2010-01-06 03:52:25 +00:00
|
|
|
}
|
|
|
|
|
2010-01-07 03:52:04 +00:00
|
|
|
/**
|
2010-01-09 16:20:47 +00:00
|
|
|
* Paints the start of the response from the test suite.
|
2010-01-07 03:52:04 +00:00
|
|
|
* Used to paint things like head elements in an html page.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
public function paintDocumentStart() {
|
2010-01-07 03:52:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-01-09 16:20:47 +00:00
|
|
|
* Paints the end of the response from the test suite.
|
2010-01-07 03:52:04 +00:00
|
|
|
* Used to paint things like </body> in an html page.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
public function paintDocumentEnd() {
|
2011-02-21 19:51:26 +00:00
|
|
|
|
2010-01-09 16:20:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Paint a list of test sets, core, app, and plugin test sets
|
|
|
|
* available.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
public function paintTestMenu() {
|
2011-02-21 19:51:26 +00:00
|
|
|
|
2010-01-06 03:52:25 +00:00
|
|
|
}
|
|
|
|
|
2010-01-09 16:20:47 +00:00
|
|
|
/**
|
|
|
|
* Get the baseUrl if one is available.
|
|
|
|
*
|
|
|
|
* @return string The base url for the request.
|
|
|
|
*/
|
2010-04-15 02:56:51 +00:00
|
|
|
public function baseUrl() {
|
2010-01-09 16:20:47 +00:00
|
|
|
if (!empty($_SERVER['PHP_SELF'])) {
|
|
|
|
return $_SERVER['PHP_SELF'];
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2011-02-12 23:39:25 +00:00
|
|
|
public function printResult(PHPUnit_Framework_TestResult $result) {
|
|
|
|
$this->paintFooter($result);
|
|
|
|
}
|
|
|
|
|
2010-05-13 04:18:22 +00:00
|
|
|
public function paintResult(PHPUnit_Framework_TestResult $result) {
|
|
|
|
$this->paintFooter($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An error occurred.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param Exception $e
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
2010-07-15 02:58:42 +00:00
|
|
|
$this->paintException($e, $test);
|
2010-05-13 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A failure occurred.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param PHPUnit_Framework_AssertionFailedError $e
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) {
|
2010-07-15 02:58:42 +00:00
|
|
|
$this->paintFail($e, $test);
|
2010-05-13 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Incomplete test.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param Exception $e
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
2010-06-12 22:55:27 +00:00
|
|
|
$this->paintSkip($e, $test);
|
2010-05-13 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skipped test.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param Exception $e
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) {
|
2010-05-18 03:01:22 +00:00
|
|
|
$this->paintSkip($e, $test);
|
2010-05-13 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A test suite started.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_TestSuite $suite
|
|
|
|
*/
|
|
|
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
2011-02-13 04:07:39 +00:00
|
|
|
if (!$this->_headerSent) {
|
|
|
|
echo $this->paintHeader();
|
|
|
|
}
|
2011-03-20 15:35:43 +00:00
|
|
|
echo __d('cake_dev', 'Running %s', $suite->getName()) . "\n";
|
2010-05-13 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A test suite ended.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_TestSuite $suite
|
|
|
|
*/
|
|
|
|
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A test started.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
*/
|
|
|
|
public function startTest(PHPUnit_Framework_Test $test) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A test ended.
|
|
|
|
*
|
|
|
|
* @param PHPUnit_Framework_Test $test
|
|
|
|
* @param float $time
|
|
|
|
*/
|
|
|
|
public function endTest(PHPUnit_Framework_Test $test, $time) {
|
|
|
|
$this->numAssertions += $test->getNumAssertions();
|
|
|
|
$this->paintPass($test, $time);
|
|
|
|
}
|
|
|
|
|
2011-03-19 17:35:14 +00:00
|
|
|
}
|