mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
adding test method for testing the running of a testcase (doh!) to the test manager test case
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7840 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e882d990d7
commit
be6c24503d
2 changed files with 33 additions and 4 deletions
|
@ -28,10 +28,25 @@
|
|||
*/
|
||||
App::import('Core', 'TestManager');
|
||||
class TestManagerTest extends CakeTestCase {
|
||||
/**
|
||||
* undocumented function
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function setUp() {
|
||||
$this->Sut = new TestManager();
|
||||
$this->Reporter = new CakeHtmlReporter();
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testRunAllTests() {
|
||||
$manager = new TestManager();
|
||||
$folder = new Folder($manager->_getTestsPath());
|
||||
$extension = str_replace('.', '\.', Testmanager::getExtension('test'));
|
||||
$folder = new Folder($this->Sut->_getTestsPath());
|
||||
$extension = str_replace('.', '\.', TestManager::getExtension('test'));
|
||||
$out = $folder->findRecursive('.*' . $extension);
|
||||
|
||||
$reporter = new CakeHtmlReporter();
|
||||
|
@ -46,7 +61,14 @@ class TestManagerTest extends CakeTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function testRunTestCase() {
|
||||
$file = md5(time());
|
||||
$result = $this->Sut->runTestCase($file, $this->Reporter);
|
||||
$this->assertError('Test case ' . $file . ' cannot be found');
|
||||
$this->assertFalse($result);
|
||||
|
||||
$file = str_replace(CORE_TEST_CASES, '', __FILE__);
|
||||
$result = $this->Sut->runTestCase($file, $this->Reporter, true);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
|
|
|
@ -106,13 +106,20 @@ class TestManager {
|
|||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function runTestCase($testCaseFile, &$reporter) {
|
||||
function runTestCase($testCaseFile, &$reporter, $testing = false) {
|
||||
$manager =& new TestManager();
|
||||
|
||||
$testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile;
|
||||
|
||||
if (!file_exists($testCaseFileWithPath)) {
|
||||
trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($testing) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$test =& new GroupTest("Individual test case: " . $testCaseFile);
|
||||
$test->addTestFile($testCaseFileWithPath);
|
||||
return $test->run($reporter);
|
||||
|
|
Loading…
Add table
Reference in a new issue