mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Adding test for TestManager::runGroupTest()
This commit is contained in:
parent
856a52a378
commit
fd4a82d6e9
2 changed files with 20 additions and 4 deletions
|
@ -51,10 +51,17 @@ class TestManagerTest extends CakeTestCase {
|
|||
$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 @@ class TestManagerTest extends CakeTestCase {
|
|||
$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 @@ class TestManagerTest extends CakeTestCase {
|
|||
* @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 @@ class TestManager {
|
|||
$test->addTestFile($testCase);
|
||||
}
|
||||
|
||||
return $test->run($reporter);
|
||||
return $this->run($reporter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue