mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Using PHPUnit internals for more things.
Removing code that is also present in PHPUnit. Updating testsuite shell to use loader class.
This commit is contained in:
parent
e5c898a4d2
commit
39e05bce4a
4 changed files with 13 additions and 39 deletions
|
@ -167,6 +167,7 @@ class TestSuiteShell extends Shell {
|
||||||
|
|
||||||
$this->_dispatcher = new CakeTestSuiteDispatcher();
|
$this->_dispatcher = new CakeTestSuiteDispatcher();
|
||||||
$this->_dispatcher->loadTestFramework();
|
$this->_dispatcher->loadTestFramework();
|
||||||
|
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,7 +256,6 @@ class TestSuiteShell extends Shell {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function run($runnerArgs, $options = array()) {
|
protected function run($runnerArgs, $options = array()) {
|
||||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
|
|
||||||
|
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
@ -271,7 +271,7 @@ class TestSuiteShell extends Shell {
|
||||||
*/
|
*/
|
||||||
public function available() {
|
public function available() {
|
||||||
$params = $this->parseArgs();
|
$params = $this->parseArgs();
|
||||||
$testCases = TestManager::getTestCaseList($params);
|
$testCases = CakeTestLoader::generateTestList($params);
|
||||||
$app = $params['app'];
|
$app = $params['app'];
|
||||||
$plugin = $params['plugin'];
|
$plugin = $params['plugin'];
|
||||||
|
|
||||||
|
|
|
@ -28,29 +28,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
||||||
*/
|
*/
|
||||||
class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
||||||
|
|
||||||
/**
|
protected $_headerSent = false;
|
||||||
* Time the test runs started.
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_timeStart = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Time the test runs ended
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_timeEnd = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Duration of all test methods.
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
* @access protected
|
|
||||||
*/
|
|
||||||
protected $_timeDuration = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of request parameters. Usually parsed GET params.
|
* Array of request parameters. Usually parsed GET params.
|
||||||
|
@ -71,6 +49,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
||||||
* The number of assertions done for a test suite
|
* The number of assertions done for a test suite
|
||||||
*/
|
*/
|
||||||
protected $numAssertions = 0;
|
protected $numAssertions = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does nothing yet. The first output will
|
* Does nothing yet. The first output will
|
||||||
* be sent on the first test start.
|
* be sent on the first test start.
|
||||||
|
@ -205,6 +184,9 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter {
|
||||||
* @param PHPUnit_Framework_TestSuite $suite
|
* @param PHPUnit_Framework_TestSuite $suite
|
||||||
*/
|
*/
|
||||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
|
||||||
|
if (!$this->_headerSent) {
|
||||||
|
echo $this->paintHeader();
|
||||||
|
}
|
||||||
echo __('Running %s', $suite->getName()) . "\n";
|
echo __('Running %s', $suite->getName()) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
||||||
*/
|
*/
|
||||||
class CakeHtmlReporter extends CakeBaseReporter {
|
class CakeHtmlReporter extends CakeBaseReporter {
|
||||||
|
|
||||||
protected $_headerSent = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paints the top of the web page setting the
|
* Paints the top of the web page setting the
|
||||||
* title to the name of the starting test.
|
* title to the name of the starting test.
|
||||||
|
@ -142,10 +140,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
||||||
echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
|
echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
echo '<div style="padding:0 0 5px;">';
|
echo '<div style="padding:0 0 5px;">';
|
||||||
echo '<p><strong>Time taken by tests (in seconds):</strong> ' . $result->time() . '</p>';
|
echo '<p><strong>' . PHP_Timer::resourceUsage() . '</strong>';
|
||||||
if (function_exists('memory_get_peak_usage')) {
|
|
||||||
echo '<p><strong>Peak memory use: (in bytes):</strong> ' . number_format(memory_get_peak_usage()) . '</p>';
|
|
||||||
}
|
|
||||||
echo $this->_paintLinks();
|
echo $this->_paintLinks();
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
|
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
|
||||||
|
|
|
@ -35,9 +35,9 @@ class CakeTextReporter extends CakeBaseReporter {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function paintDocumentStart() {
|
public function paintDocumentStart() {
|
||||||
if (!headers_sent()) {
|
// if (!headers_sent()) {
|
||||||
header('Content-type: text/plain');
|
header('Content-type: text/plain');
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,10 +87,8 @@ class CakeTextReporter extends CakeBaseReporter {
|
||||||
', Failures: ' . $result->failureCount() .
|
', Failures: ' . $result->failureCount() .
|
||||||
', Exceptions: ' . $result->errorCount() . "\n";
|
', Exceptions: ' . $result->errorCount() . "\n";
|
||||||
|
|
||||||
echo 'Time taken by tests (in seconds): ' . $result->time() . "\n";
|
echo PHP_Timer::resourceUsage();
|
||||||
if (function_exists('memory_get_peak_usage')) {
|
|
||||||
echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n";
|
|
||||||
}
|
|
||||||
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
|
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
|
||||||
$coverage = $result->getCodeCoverageInformation();
|
$coverage = $result->getCodeCoverageInformation();
|
||||||
echo $this->paintCoverage($coverage);
|
echo $this->paintCoverage($coverage);
|
||||||
|
@ -129,8 +127,7 @@ class CakeTextReporter extends CakeBaseReporter {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function paintSkip($message) {
|
public function paintSkip($message) {
|
||||||
parent::paintSkip($message);
|
printf("Skip: %s\n", $message->getMessage());
|
||||||
echo "Skip: $message\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue