Skip to content
Permalink
Browse files

Adding test for TestManager::runGroupTest()

  • Loading branch information...
lorenzo committed May 5, 2010
1 parent 856a52a commit fd4a82d6e909ebddf2b3b3f97a4af18ceb78d6c0
Showing with 20 additions and 4 deletions.
  1. +19 −3 cake/tests/cases/libs/test_manager.test.php
  2. +1 −1 cake/tests/lib/test_manager.php
@@ -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');
}
@@ -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();
@@ -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);
}
/**
@@ -102,7 +102,7 @@ public function runAllTests(&$reporter) {
$test->addTestFile($testCase);
}
return $test->run($reporter);
return $this->run($reporter);
}
/**

0 comments on commit fd4a82d

Please sign in to comment.
You can’t perform that action at this time.