Skip to content

Commit

Permalink
Fixing / adding visibility.
Browse files Browse the repository at this point in the history
Removing DS usage as its not needed in php5.
Removing reference operators.
  • Loading branch information
markstory committed Apr 15, 2010
1 parent 50243f3 commit 7705c40
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 52 deletions.
30 changes: 18 additions & 12 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Expand Up @@ -69,6 +69,13 @@ class CakeTestSuiteDispatcher {
*/
protected $_baseDir;

/**
* reporter instance used for the request
*
* @var CakeBaseReporter
*/
protected static $_Reporter = null;

/**
* constructor
*
Expand Down Expand Up @@ -109,9 +116,9 @@ function dispatch() {
* @return void
*/
function _checkSimpleTest() {
if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
if (!App::import('Vendor', 'simpletest/reporter')) {
$baseDir = $this->_baseDir;
include CAKE_TESTS_LIB . 'templates' . DS . 'simpletest.php';
include CAKE_TESTS_LIB . 'templates/simpletest.php';
exit();
}
}
Expand All @@ -125,7 +132,7 @@ function _checkSimpleTest() {
function _checkXdebug() {
if (!extension_loaded('xdebug')) {
$baseDir = $this->_baseDir;
include CAKE_TESTS_LIB . 'templates' . DS . 'xdebug.php';
include CAKE_TESTS_LIB . 'templates/xdebug.php';
exit();
}
}
Expand Down Expand Up @@ -176,21 +183,20 @@ function &getManager() {
* @static
*/
function &getReporter() {
static $Reporter = NULL;
if (!$Reporter) {
if (!self::$_Reporter) {
$type = strtolower($this->params['output']);
$coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter';
$coreFile = CAKE_TESTS_LIB . 'reporter' . DS . 'cake_' . $type . '_reporter.php';
$coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php';

$appClass = $this->params['output'] . 'Reporter';
$appFile = APPLIBS . 'test_suite' . DS . 'reporter' . DS . $type . '_reporter.php';
$appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php';
if (include_once $coreFile) {
$Reporter =& new $coreClass(null, $this->params);
self::$_Reporter = new $coreClass(null, $this->params);
} elseif (include_once $appFile) {
$Reporter =& new $appClass(null, $this->params);
self::$_Reporter = new $appClass(null, $this->params);
}
}
return $Reporter;
return self::$_Reporter;
}

/**
Expand Down Expand Up @@ -223,7 +229,7 @@ function _parseParams() {
* @return void
*/
function _runGroupTest() {
$Reporter =& CakeTestSuiteDispatcher::getReporter();
$Reporter = CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['group'], $Reporter);
}
Expand All @@ -240,7 +246,7 @@ function _runGroupTest() {
* @return void
*/
function _runTestCase() {
$Reporter =& CakeTestSuiteDispatcher::getReporter();
$Reporter = CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['case'], $Reporter);
}
Expand Down
72 changes: 36 additions & 36 deletions cake/tests/lib/code_coverage_manager.php
Expand Up @@ -77,7 +77,7 @@ class CodeCoverageManager {
*
* @return object
*/
public function &getInstance() {
public static function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& new CodeCoverageManager();
Expand All @@ -93,8 +93,8 @@ public function &getInstance() {
* @return void
* @static
*/
function init($testCaseFile, &$reporter) {
$manager =& CodeCoverageManager::getInstance();
public static function init($testCaseFile, &$reporter) {
$manager = CodeCoverageManager::getInstance();
$manager->reporter =& $reporter;
$testCaseFile = str_replace(DS . DS, DS, $testCaseFile);
$thisFile = str_replace('.php', '.test.php', basename(__FILE__));
Expand All @@ -112,7 +112,7 @@ function init($testCaseFile, &$reporter) {
* @return void
* @static
*/
function start() {
public static function start() {
xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
}

Expand All @@ -123,7 +123,7 @@ function start() {
* @return void
* @static
*/
function stop() {
public static function stop() {
xdebug_stop_code_coverage(false);
}

Expand All @@ -134,7 +134,7 @@ function stop() {
* @return void
* @static
*/
function clear() {
public static function clear() {
xdebug_stop_code_coverage();
}

Expand All @@ -143,7 +143,7 @@ function clear() {
*
* @return void
*/
function setParams(&$reporter) {
public static function setParams(&$reporter) {
if ($reporter->params['app']) {
$this->appTest = true;
}
Expand All @@ -164,8 +164,8 @@ function setParams(&$reporter) {
* @return void
* @static
*/
function report($output = true) {
$manager =& CodeCoverageManager::getInstance();
public static function report($output = true) {
$manager = CodeCoverageManager::getInstance();

CodeCoverageManager::stop();
CodeCoverageManager::clear();
Expand Down Expand Up @@ -214,7 +214,7 @@ function report($output = true) {
*
* @return void
*/
function _getCoverageData() {
protected function _getCoverageData() {
$coverageData = array();
$dump = xdebug_get_code_coverage();

Expand Down Expand Up @@ -256,7 +256,7 @@ function _getCoverageData() {
* @return void
* @static
*/
function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
public static function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
$total = count($testObjectFile);
$lines = array();
Expand Down Expand Up @@ -375,7 +375,7 @@ function reportCaseHtmlDiff($testObjectFile, $coverageData, $execCodeLines, $num
* @return void
* @static
*/
function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
public static function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
$lineCount = $coveredCount = 0;
$report = '';
Expand Down Expand Up @@ -406,7 +406,7 @@ function reportCaseCli($testObjectFile, $coverageData, $execCodeLines) {
* @return void
* @static
*/
function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
public static function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numContextLines) {
$manager = CodeCoverageManager::getInstance();
$report = '';

Expand Down Expand Up @@ -447,7 +447,7 @@ function reportGroupHtml($testObjectFiles, $coverageData, $execCodeLines, $numCo
* @return void
* @static
*/
function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
public static function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
$manager = CodeCoverageManager::getInstance();
$report = '';

Expand Down Expand Up @@ -482,7 +482,7 @@ function reportGroupCli($testObjectFiles, $coverageData, $execCodeLines) {
* @return string name of the test object file
* @access private
*/
function __testObjectFileFromCaseFile($file, $isApp = true) {
private function __testObjectFileFromCaseFile($file, $isApp = true) {
$manager = CodeCoverageManager::getInstance();
$path = $manager->__getTestFilesPath($isApp);
$folderPrefixMap = array(
Expand All @@ -497,10 +497,10 @@ function __testObjectFileFromCaseFile($file, $isApp = true) {
break;
}
}
$testManager =& new TestManager();
$testFile = str_replace(array('/', $testManager->_testExtension), array(DS, '.php'), $file);
$testManager = new TestManager();
$testFile = str_replace(array('/', $testManager->getExtension('test')), array(DS, '.php'), $file);

$folder =& new Folder();
$folder = new Folder();
$folder->cd(ROOT . DS . CAKE_TESTS_LIB);
$contents = $folder->read();

Expand All @@ -525,9 +525,9 @@ function __testObjectFileFromCaseFile($file, $isApp = true) {
* @return array names of the test object files
* @access private
*/
function __testObjectFilesFromGroupFile($groupFile, $isApp = true) {
private function __testObjectFilesFromGroupFile($groupFile, $isApp = true) {
$manager = CodeCoverageManager::getInstance();
$testManager =& new TestManager();
$testManager = new TestManager();

$path = TESTS;
if (!$isApp) {
Expand Down Expand Up @@ -585,9 +585,9 @@ function __testObjectFilesFromGroupFile($groupFile, $isApp = true) {
* @return array array of lines
* @access private
*/
function __getExecutableLines($content) {
private function __getExecutableLines($content) {
if (is_array($content)) {
$manager =& CodeCoverageManager::getInstance();
$manager = CodeCoverageManager::getInstance();
$result = array();
foreach ($content as $file) {
$result[$file] = $manager->__getExecutableLines(file_get_contents($file));
Expand Down Expand Up @@ -616,7 +616,7 @@ function __getExecutableLines($content) {
* @return string the number of newlines in a given arg
* @access private
*/
function __replaceWithNewlines() {
private function __replaceWithNewlines() {
$args = func_get_args();
$numLineBreaks = count(explode("\n", $args[0][0]));
return str_pad('', $numLineBreaks - 1, "\n");
Expand All @@ -630,8 +630,8 @@ function __replaceWithNewlines() {
* @return void
* @access private
*/
function __paintHeader($lineCount, $coveredCount, $report) {
$manager =& CodeCoverageManager::getInstance();
private function __paintHeader($lineCount, $coveredCount, $report) {
$manager = CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
return $report = '<h2>Code Coverage: ' . $codeCoverage . '%</h2>
<div class="code-coverage-results"><pre>' . $report . '</pre></div>';
Expand All @@ -642,7 +642,7 @@ function __paintHeader($lineCount, $coveredCount, $report) {
*
* @return void
*/
public function __paintGroupResultHeader($report) {
private function __paintGroupResultHeader($report) {
return '<div class="code-coverage-results"><p class="note">Please keep in mind that the coverage can vary a little bit depending on how much the different tests in the group interfere. If for example, TEST A calls a line from TEST OBJECT B, the coverage for TEST OBJECT B will be a little greater than if you were running the corresponding test case for TEST OBJECT B alone.</p><pre>' . $report . '</pre></div>';
}

Expand All @@ -654,8 +654,8 @@ public function __paintGroupResultHeader($report) {
* @return void
* @access private
*/
function __paintGroupResultLine($file, $lineCount, $coveredCount) {
$manager =& CodeCoverageManager::getInstance();
private function __paintGroupResultLine($file, $lineCount, $coveredCount) {
$manager = CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'result-bad';

Expand All @@ -676,8 +676,8 @@ function __paintGroupResultLine($file, $lineCount, $coveredCount) {
* @return void
* @access private
*/
function __paintGroupResultLineCli($file, $lineCount, $coveredCount) {
$manager =& CodeCoverageManager::getInstance();
private function __paintGroupResultLineCli($file, $lineCount, $coveredCount) {
$manager = CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'bad';
if ($codeCoverage > 50) {
Expand All @@ -697,8 +697,8 @@ function __paintGroupResultLineCli($file, $lineCount, $coveredCount) {
* @return void
* @access private
*/
function __paintHeaderCli($lineCount, $coveredCount, $report) {
$manager =& CodeCoverageManager::getInstance();
private function __paintHeaderCli($lineCount, $coveredCount, $report) {
$manager = CodeCoverageManager::getInstance();
$codeCoverage = $manager->__calcCoverage($lineCount, $coveredCount);
$class = 'bad';
if ($codeCoverage > 50) {
Expand All @@ -716,7 +716,7 @@ function __paintHeaderCli($lineCount, $coveredCount, $report) {
* @package default
* @access private
*/
function __paintCodeline($class, $num, $line) {
private function __paintCodeline($class, $num, $line) {
$line = h($line);

if (trim($line) == '') {
Expand All @@ -733,7 +733,7 @@ function __paintCodeline($class, $num, $line) {
* @return void
* @access private
*/
function __calcCoverage($lineCount, $coveredCount) {
private function __calcCoverage($lineCount, $coveredCount) {
if ($coveredCount > $lineCount) {
trigger_error(__('Sorry, you cannot have more covered lines than total lines!', true));
}
Expand All @@ -748,7 +748,7 @@ function __calcCoverage($lineCount, $coveredCount) {
* @param string $isApp
* @return void
*/
public function __getTestFilesPath($isApp = true) {
private function __getTestFilesPath($isApp = true) {
$manager = CodeCoverageManager::getInstance();
$path = ROOT . DS;

Expand Down Expand Up @@ -782,7 +782,7 @@ public function __getTestFilesPath($isApp = true) {
* @return void
* @access private
*/
function __array_strpos($arr, $needle, $reverse = false) {
private function __array_strpos($arr, $needle, $reverse = false) {
if (!is_array($arr) || empty($arr)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/reporter/cake_base_reporter.php
Expand Up @@ -81,7 +81,7 @@ class CakeBaseReporter extends SimpleReporter {
* @param array $params Array of request parameters the reporter should use. See above.
*/
function __construct($charset = 'utf-8', $params = array()) {
$this->SimpleReporter();
parent::__construct();
if (!$charset) {
$charset = 'utf-8';
}
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/reporter/cake_html_reporter.php
Expand Up @@ -238,7 +238,7 @@ protected function _queryString($url) {
*/
public function paintDocumentEnd() {
$baseDir = $this->params['baseDir'];
include CAKE_TESTS_LIB . 'templates' . DS . 'footer.php';
include CAKE_TESTS_LIB . 'templates/footer.php';
ob_end_flush();
}

Expand Down
4 changes: 2 additions & 2 deletions cake/tests/lib/test_manager.php
Expand Up @@ -176,7 +176,7 @@ public function runGroupTest($groupTestName, &$reporter) {
* @access public
* @static
*/
function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
public static function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
$manager = new TestManager();
$testCases = $manager->_getTestFileList($directory);
foreach ($testCases as $testCase) {
Expand All @@ -193,7 +193,7 @@ function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
* @access public
* @static
*/
function addTestFile(&$groupTest, $file) {
public static function addTestFile(&$groupTest, $file) {
$manager = new TestManager();

if (file_exists($file . $manager->_testExtension)) {
Expand Down

0 comments on commit 7705c40

Please sign in to comment.