Skip to content

Commit

Permalink
Adding test for TestManager::runGroupTest()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 5, 2010
1 parent 856a52a commit fd4a82d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions cake/tests/cases/libs/test_manager.test.php
Expand Up @@ -51,10 +51,17 @@ public function setUp() {
$this->_countFiles = 0;
$this->TestManager = new TestTestManager();
$this->testSuiteStub = $this->getMock('PHPUnit_Framework_TestSuite');

$this->testSuiteStub
->expects($this->any())
->method('addTestFile')
->will($this->returnCallback(array(&$this, '_countIncludedTestFiles')));

$this->testSuiteStub
->expects($this->any())
->method('addTestSuite')
->will($this->returnCallback(array(&$this, '_countIncludedTestFiles')));

$this->TestManager->setTestSuite($this->testSuiteStub);
$this->Reporter = $this->getMock('CakeHtmlReporter');
}
Expand All @@ -68,9 +75,9 @@ public function _countIncludedTestFiles() {
$this->_countFiles++;
}

protected function _getAllTestFiles() {
$folder = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(CORE_TEST_CASES));
$extension = str_replace('.', '\.', $this->TestManager->getExtension('test'));
protected function _getAllTestFiles($directory = CORE_TEST_CASES, $type = 'test') {
$folder = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
$extension = str_replace('.', '\.', $this->TestManager->getExtension($type));
$out = new RegexIterator($folder, '#^.+'.$extension.'$#i', RecursiveRegexIterator::GET_MATCH);

$files = array();
Expand Down Expand Up @@ -120,6 +127,15 @@ public function testRunTestCase() {
* @return void
*/
public function testRunGroupTest() {
$groups = $this->_getAllTestFiles(CORE_TEST_GROUPS, 'group');
if (empty($groups)) {
$this->markTestSkipped('No test group files');
return;
}
list($groupFile,) = explode('.', array_pop($groups), 2);
$result = $this->TestManager->runGroupTest(basename($groupFile), $this->Reporter);
$this->assertGreaterThan(0, $this->_countFiles);
$this->assertType('PHPUnit_Framework_TestResult', $result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/test_manager.php
Expand Up @@ -102,7 +102,7 @@ public function runAllTests(&$reporter) {
$test->addTestFile($testCase);
}

return $test->run($reporter);
return $this->run($reporter);
}

/**
Expand Down

0 comments on commit fd4a82d

Please sign in to comment.