mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
0a2822335c
commit
8c2e0815ec
3 changed files with 39 additions and 3 deletions
|
@ -143,6 +143,8 @@ class TestSuiteShell extends Shell {
|
|||
))->addOption('directive', array(
|
||||
'help' => __('key[=value] Sets a php.ini value.'),
|
||||
'default' => false
|
||||
))->addOption('fixture', array(
|
||||
'help' => __('Choose a custom fixture manager.'),
|
||||
));
|
||||
|
||||
return $parser;
|
||||
|
|
|
@ -27,16 +27,39 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
|||
*/
|
||||
class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
|
||||
|
||||
/**
|
||||
* Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
|
||||
*
|
||||
* @param PHPUnit_Framework_Test $suite
|
||||
* @param array $arguments
|
||||
* @return void
|
||||
*/
|
||||
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {
|
||||
$fixture = new CakeFixtureManager;
|
||||
$fixture = $this->_getFixtureManager($arguments);
|
||||
foreach ($suite->getIterator() as $test) {
|
||||
if ($test instanceof CakeTestCase) {
|
||||
$fixture->fixturize($test);
|
||||
$test->fixtureManager = $fixture;
|
||||
}
|
||||
}
|
||||
$r = parent::doRun($suite, $arguments);
|
||||
$return = parent::doRun($suite, $arguments);
|
||||
$fixture->shutdown();
|
||||
return $r;
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fixture manager class specified or use the default one.
|
||||
*
|
||||
* @return instance of a fixture manager.
|
||||
*/
|
||||
protected function _getFixtureManager($arguments) {
|
||||
if (!isset($arguments['fixtureManager'])) {
|
||||
return new CakeFixtureManager();
|
||||
}
|
||||
App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManagerΩ']));
|
||||
if (class_exists($arguments['fixtureManager'])) {
|
||||
return new $arguments['fixtureManager'];
|
||||
}
|
||||
throw new Exception('No fixture manager found.');
|
||||
}
|
||||
}
|
|
@ -47,6 +47,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
|||
$this->arguments['test'] = $params['case'];
|
||||
$this->arguments['testFile'] = $params;
|
||||
$this->_params = $params;
|
||||
|
||||
$this->longOptions['fixture='] = 'handleFixture';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,4 +129,13 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for customizing the FixtureManager class/
|
||||
*
|
||||
* @param string $class Name of the class that will be the fixture manager
|
||||
* @return void
|
||||
*/
|
||||
function handleFixture($class) {
|
||||
$this->arguments['fixtureManager'] = $class;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue