diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php index b4e5defa3a7..2fd4c86b355 100644 --- a/cake/tests/cases/libs/test_manager.test.php +++ b/cake/tests/cases/libs/test_manager.test.php @@ -50,7 +50,7 @@ class TestManagerTest extends CakeTestCase { public function setUp() { $this->_countFiles = 0; $this->TestManager = new TestTestManager(); - $this->testSuiteStub = $this->getMock('PHPUnit_Framework_TestSuite'); + $this->testSuiteStub = $this->getMock('CakeTestSuite'); $this->testSuiteStub ->expects($this->any()) @@ -93,6 +93,7 @@ protected function _getAllTestFiles($directory = CORE_TEST_CASES, $type = 'test' * @return void */ public function testRunAllTests() { + $this->Reporter->params = array('show' => 'cases'); $files = $this->_getAllTestFiles(); $result = $this->TestManager->runAllTests($this->Reporter, true); @@ -115,7 +116,7 @@ public function testRunUnexistentCase() { * @return void */ public function testRunTestCase() { - $file = str_replace(CORE_TEST_CASES, '', __FILE__); + $file = __FILE__; $result = $this->TestManager->runTestCase($file, $this->Reporter, true); $this->assertEquals(1, $this->_countFiles); $this->assertType('PHPUnit_Framework_TestResult', $result); @@ -133,7 +134,7 @@ public function testRunGroupTest() { return; } list($groupFile,) = explode('.', array_pop($groups), 2); - $result = $this->TestManager->runGroupTest(basename($groupFile), $this->Reporter); + $result = $this->TestManager->runGroupTest($groupFile, $this->Reporter); $this->assertGreaterThan(0, $this->_countFiles); $this->assertType('PHPUnit_Framework_TestResult', $result); } diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 2f322cf43d2..65d3a5fbedf 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -87,7 +87,7 @@ class TestManager { * * @return void */ - public function __construct($params) { + public function __construct($params = array()) { require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); if (isset($params['app'])) { $this->appTest = true; @@ -111,7 +111,7 @@ public function __construct($params) { * @return mixed */ public function runAllTests(&$reporter) { - $testCases = $this->_getTestFileList($this->_getTestsPath()); + $testCases = $this->_getTestFileList($this->_getTestsPath($reporter->params)); if ($this->appTest) { $test = $this->getTestSuite(__('All App Tests', true)); @@ -157,7 +157,7 @@ public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $repor * @return mixed Results of group test being run. */ public function runGroupTest($groupTestName, $reporter, $codeCoverage = false) { - $filePath = $this->_getTestsPath($reporter->params) . DS . strtolower($groupTestName) . $this->getExtension('group'); + $filePath = $this->_getTestsPath($reporter->params) . strtolower($groupTestName) . $this->getExtension('group'); if (!file_exists($filePath) || strpos($filePath, '..')) { throw new InvalidArgumentException(sprintf( @@ -169,8 +169,9 @@ public function runGroupTest($groupTestName, $reporter, $codeCoverage = false) { } require_once $filePath; - $suite = $this->getTestSuite(sprintf(__('%s group test', true), $groupTestName)); - $groupClassName = Inflector::classify($groupTestName) . 'GroupTest'; + $class = basename($groupTestName); + $suite = $this->getTestSuite(sprintf(__('%s group test', true), $class)); + $groupClassName = Inflector::classify($class) . 'GroupTest'; $group = new $groupClassName(); $suite->addTestSuite($group); if (isset($group->label)) { @@ -361,6 +362,7 @@ protected static function _hasExpectedExtension($file, $extension) { * @static */ protected static function _getTestsPath($params) { + $result = null; if (!empty($params['app'])) { if ($params['show'] == 'cases' || !empty($params['case'])) { $result = APP_TEST_CASES; @@ -374,7 +376,7 @@ protected static function _getTestsPath($params) { $_pluginBasePath = $pluginPath . DS . 'tests'; } $result = $_pluginBasePath . DS . $type; - } else { + } elseif (!empty($params['show'])) { if ($params['show'] == 'cases' || !empty($params['case'])) { $result = CORE_TEST_CASES; } else if ($params['show'] == 'groups') {