mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Running individual tests from the web runner now works.
Adding some more hooks, so webrunner can swap out result printers like it did before.
This commit is contained in:
parent
8ebbccbd76
commit
16481d7b7e
5 changed files with 59 additions and 11 deletions
|
@ -35,6 +35,10 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {
|
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {
|
||||||
|
if (isset($arguments['printer'])) {
|
||||||
|
self::$versionStringPrinted = true;
|
||||||
|
}
|
||||||
|
|
||||||
$fixture = $this->_getFixtureManager($arguments);
|
$fixture = $this->_getFixtureManager($arguments);
|
||||||
foreach ($suite->getIterator() as $test) {
|
foreach ($suite->getIterator() as $test) {
|
||||||
if ($test instanceof CakeTestCase) {
|
if ($test instanceof CakeTestCase) {
|
||||||
|
@ -42,6 +46,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
|
||||||
$test->fixtureManager = $fixture;
|
$test->fixtureManager = $fixture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = parent::doRun($suite, $arguments);
|
$return = parent::doRun($suite, $arguments);
|
||||||
$fixture->shutdown();
|
$fixture->shutdown();
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -49,6 +49,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
||||||
$this->_params = $params;
|
$this->_params = $params;
|
||||||
|
|
||||||
$this->longOptions['fixture='] = 'handleFixture';
|
$this->longOptions['fixture='] = 'handleFixture';
|
||||||
|
$this->longOptions['output='] = 'handleReporter';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,4 +141,26 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
||||||
function handleFixture($class) {
|
function handleFixture($class) {
|
||||||
$this->arguments['fixtureManager'] = $class;
|
$this->arguments['fixtureManager'] = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles output flag used to change printing on webrunner.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handleReporter($reporter) {
|
||||||
|
$object = null;
|
||||||
|
|
||||||
|
$type = strtolower($reporter);
|
||||||
|
$coreClass = 'Cake' . ucwords($reporter) . 'Reporter';
|
||||||
|
$coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php';
|
||||||
|
|
||||||
|
$appClass = $reporter . 'Reporter';
|
||||||
|
$appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php';
|
||||||
|
if (include_once $coreFile) {
|
||||||
|
$object = new $coreClass(null, $this->_params);
|
||||||
|
} elseif (include_once $appFile) {
|
||||||
|
$object = new $appClass(null, $this->_params);
|
||||||
|
}
|
||||||
|
$this->arguments['printer'] = $object;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -39,13 +39,6 @@ class CakeTestSuiteDispatcher {
|
||||||
'filter' => false
|
'filter' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* The classname for the TestManager being used
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $_managerClass = 'TestManager';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Instance of the Manager being used.
|
* The Instance of the Manager being used.
|
||||||
*
|
*
|
||||||
|
@ -260,9 +253,11 @@ class CakeTestSuiteDispatcher {
|
||||||
$this->_checkXdebug();
|
$this->_checkXdebug();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (empty($this->params['plugin']) && empty($this->params['app'])) {
|
||||||
|
$this->params['core'] = true;
|
||||||
|
}
|
||||||
$this->params['baseUrl'] = $this->_baseUrl;
|
$this->params['baseUrl'] = $this->_baseUrl;
|
||||||
$this->params['baseDir'] = $this->_baseDir;
|
$this->params['baseDir'] = $this->_baseDir;
|
||||||
$this->getManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -271,9 +266,28 @@ class CakeTestSuiteDispatcher {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _runTestCase() {
|
function _runTestCase() {
|
||||||
try {
|
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
|
||||||
|
|
||||||
$Reporter = CakeTestSuiteDispatcher::getReporter();
|
$Reporter = CakeTestSuiteDispatcher::getReporter();
|
||||||
return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']);
|
|
||||||
|
$commandArgs = array(
|
||||||
|
'case' => $this->params['case'],
|
||||||
|
'core' =>$this->params['core'],
|
||||||
|
'app' => $this->params['app'],
|
||||||
|
'plugin' => $this->params['plugin'],
|
||||||
|
'codeCoverage' => $this->params['codeCoverage'],
|
||||||
|
'baseUrl' => $this->_baseUrl,
|
||||||
|
'baseDir' => $this->_baseDir,
|
||||||
|
);
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
'--filter', $this->params['filter'],
|
||||||
|
'--output', $this->params['output']
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs);
|
||||||
|
$result = $command->run($options);
|
||||||
} catch (MissingConnectionException $exception) {
|
} catch (MissingConnectionException $exception) {
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$baseDir = $this->_baseDir;
|
$baseDir = $this->_baseDir;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* @since CakePHP(tm) v 1.3
|
* @since CakePHP(tm) v 1.3
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
|
require_once 'PHPUnit/TextUi/ResultPrinter.php';
|
||||||
|
|
||||||
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
||||||
* @package cake
|
* @package cake
|
||||||
* @package cake.tests.lib
|
* @package cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class CakeBaseReporter implements PHPUnit_Framework_TestListener {
|
class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time the test runs started.
|
* Time the test runs started.
|
||||||
|
@ -146,6 +147,10 @@ class CakeBaseReporter implements PHPUnit_Framework_TestListener {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function printResult(PHPUnit_Framework_TestResult $result) {
|
||||||
|
$this->paintFooter($result);
|
||||||
|
}
|
||||||
|
|
||||||
public function paintResult(PHPUnit_Framework_TestResult $result) {
|
public function paintResult(PHPUnit_Framework_TestResult $result) {
|
||||||
$this->paintFooter($result);
|
$this->paintFooter($result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,6 +340,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
||||||
* @param PHPUnit_Framework_TestSuite $suite
|
* @param PHPUnit_Framework_TestSuite $suite
|
||||||
*/
|
*/
|
||||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
||||||
|
echo $this->paintHeader();
|
||||||
echo '<h2>' . __('Running %s', $suite->getName()) . '</h2>';
|
echo '<h2>' . __('Running %s', $suite->getName()) . '</h2>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue