mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Updating CodeCoverageManager test case and CodeCoverageManager
This commit is contained in:
parent
cf5c48ecc5
commit
836c7de7cb
2 changed files with 26 additions and 11 deletions
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php';
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php';
|
||||
|
||||
/**
|
||||
* CodeCoverageManagerTest class
|
||||
|
@ -65,12 +64,13 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
|||
*/
|
||||
function testNoTestCaseSupplied() {
|
||||
if (PHP_SAPI != 'cli') {
|
||||
unset($_GET['group']);
|
||||
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
|
||||
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
|
||||
|
||||
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
|
||||
CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), new CakeHtmlReporter());
|
||||
CodeCoverageManager::start('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
|
||||
|
@ -96,7 +96,7 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
|||
$contents[1] = array_filter($contents[1], "remove");
|
||||
|
||||
foreach ($contents[1] as $file) {
|
||||
CodeCoverageManager::start('libs'.DS.$file, new CakeHtmlReporter());
|
||||
CodeCoverageManager::start('libs'.DS.$file, $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertNoErrors('libs'.DS.$file);
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ class CodeCoverageManager {
|
|||
* @param string $testCaseFile
|
||||
* @param string $reporter
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function start($testCaseFile, &$reporter) {
|
||||
$manager =& CodeCoverageManager::getInstance();
|
||||
|
@ -103,26 +104,35 @@ class CodeCoverageManager {
|
|||
if (strpos($testCaseFile, $thisFile) !== false) {
|
||||
trigger_error('Xdebug supports no parallel coverage analysis - so this is not possible.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
$manager->setParams($reporter);
|
||||
$manager->testCaseFile = $testCaseFile;
|
||||
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parameters from a reporter to the CodeCoverageManager
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setParams(&$reporter) {
|
||||
if ($reporter->params['app']) {
|
||||
$manager->appTest = true;
|
||||
$this->appTest = true;
|
||||
}
|
||||
|
||||
if ($reporter->params['group']) {
|
||||
$manager->groupTest = true;
|
||||
$this->groupTest = true;
|
||||
}
|
||||
|
||||
if ($reporter->params['plugin']) {
|
||||
$manager->pluginTest = Inflector::underscore($reporter->params['plugin']);
|
||||
$this->pluginTest = Inflector::underscore($reporter->params['plugin']);
|
||||
}
|
||||
$manager->testCaseFile = $testCaseFile;
|
||||
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the current code coverage analyzation and dumps a nice report depending on the reporter that was passed to start()
|
||||
*
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function report($output = true) {
|
||||
$manager =& CodeCoverageManager::getInstance();
|
||||
|
@ -212,6 +222,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportCaseHtml($testObjectFile, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -248,6 +259,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -366,6 +378,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -396,6 +409,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
@ -436,6 +450,7 @@ class CodeCoverageManager {
|
|||
* @param string $execCodeLines
|
||||
* @param string $output
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
|
||||
$manager = CodeCoverageManager::getInstance();
|
||||
|
|
Loading…
Add table
Reference in a new issue