com phpruntests: Replacing status array with status object: src/testcase/output/rtTestOutputWriterList.php src/testcase/rtPhpTest.php
src/testcase/rtTestResults.php src/testcase/rtTestStatus.php src/testcase/sections/executablesections/rtCleanSection.php
src/testcase/sections/executablesections/rtFileExternalSection.php src/testcase/sections/executablesections/rtFileSection.php
src/testcase/sections/executablesections/rtSkipIfSection.php src/test

From: Date: Tue, 02 Jun 2009 19:12:08 +0000
Subject: com phpruntests: Replacing status array with status object: src/testcase/output/rtTestOutputWriterList.php src/testcase/rtPhpTest.php
src/testcase/rtTestResults.php src/testcase/rtTestStatus.php src/testcase/sections/executablesections/rtCleanSection.php
src/testcase/sections/executablesections/rtFileExternalSection.php src/testcase/sections/executablesections/rtFileSection.php
src/testcase/sections/executablesections/rtSkipIfSection.php src/test
Groups: php.qa 
Request: Send a blank email to php-qa+get-66428@lists.php.net to get a copy of this message
Commit: 99983b4cafb3f95a2479e56e2564a8b23859ef55 Author: Zoe Slattery <zoe@php.net> Tue, 2 Jun 2009 19:12:08 +0000 Parents: 5af19f18e47d77041c94fe0788891debb5f049fb Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=99983b4cafb3f95a2479e56e2564a8b23859ef55 Log: Replacing status array with status object Changed paths: M src/testcase/output/rtTestOutputWriterList.php M src/testcase/rtPhpTest.php M src/testcase/rtTestResults.php M src/testcase/rtTestStatus.php M src/testcase/sections/executablesections/rtCleanSection.php M src/testcase/sections/executablesections/rtFileExternalSection.php M src/testcase/sections/executablesections/rtFileSection.php M src/testcase/sections/executablesections/rtSkipIfSection.php M src/testgroup/rtPhpTestGroup.php M tests/testcase/rtCleanExecutionTest.php M tests/testcase/rtCookieExecutionTest.php M tests/testcase/rtDeflatePostExecutionTest.php M tests/testcase/rtExpectHeadersExecutionTest.php M tests/testcase/rtGetExecutionTest.php M tests/testcase/rtGzipPostExecutionTest.php M tests/testcase/rtPostExecutionTest.php M tests/testcase/rtPostRawExecutionTest.php M tests/testcase/rtSkipIfExecutionTest.php M tests/testcase/rtTestExecutionTest.php M tests/testcase/rtTestResultsTest.php A tests/testcase/rtTestStatusTest.php M tests/testcase/sections/executablesections/rtFileSectionTest.php

diff --git a/src/testcase/output/rtTestOutputWriterList.php b/src/testcase/output/rtTestOutputWriterList.php index 7ea7ab8..7fe7965 100644 --- a/src/testcase/output/rtTestOutputWriterList.php +++ b/src/testcase/output/rtTestOutputWriterList.php @@ -33,10 +33,11 @@ class rtTestOutputWriterList extends rtTestOutputWriter foreach ($testResults as $testResult) { $outputString = ""; $testStatus = $testResult->getStatus(); - ksort($testStatus); - foreach ($testStatus as $status => $message) { - $outputString .= strtoupper($status); - $outputString .= " " . $message; + foreach($testStatus->getName() as $name) { + if($testStatus->getValue($name)) { + $outputString .= " ". strtoupper($name); + $outputString .= " " . $testStatus->getMessage($name); + } } $outputString .= " " . $testResult->getTitle(); $outputString .= " [" . $testResult->getName() . ".phpt]"; diff --git a/src/testcase/rtPhpTest.php b/src/testcase/rtPhpTest.php index e3b5cfe..dc33ad5 100644 --- a/src/testcase/rtPhpTest.php +++ b/src/testcase/rtPhpTest.php @@ -18,7 +18,6 @@ class rtPhpTest private $testName; private $contents; - private $status; private $testStatus; private $output; private $sections; @@ -93,16 +92,15 @@ class rtPhpTest */ public function executeTest(rtRuntestsConfiguration $runConfiguration) { - $this->status = array(); if (array_key_exists('SKIPIF', $this->sections)) { - $this->status = $this->sections['SKIPIF']->run($this, $runConfiguration); + $this->testStatus = $this->sections['SKIPIF']->run($this, $runConfiguration); } - if (!array_key_exists('skip', $this->status) && !array_key_exists('bork', $this->status)) { - $this->status = array_merge($this->status, $this->fileSection->run($this, $runConfiguration)); + if (!$this->testStatus->getValue('skip') && !$this->testStatus->getValue('skip')) { + $this->testStatus = $this->fileSection->run($this, $runConfiguration); //The test can be skipped by file sections if the CGI executable is not available - if(!array_key_exists('skip', $this->status)) { + if(!$this->testStatus->getValue('skip')) { $this->output = $this->fileSection->getOutput(); $this->compareOutput(); @@ -114,8 +112,7 @@ class rtPhpTest if (array_key_exists('CLEAN', $this->sections)) { - $cleanStatus = $this->sections['CLEAN']->run($this, $runConfiguration); - $this->status = array_merge($this->status, $cleanStatus); + $this->testStatus = $this->sections['CLEAN']->run($this, $runConfiguration); } } } @@ -128,10 +125,10 @@ class rtPhpTest { $result = $this->expectSection->compare($this->output); - if ($result) { - $this->status['pass'] = ''; + if (!$result) { + $this->testStatus->setTrue('fail'); } else { - $this->status['fail'] = 'output'; + $this->testStatus->setTrue('pass'); } } @@ -144,10 +141,10 @@ class rtPhpTest { $result = $this->sections['EXPECTHEADERS']->compare($this->headers); - if ($result) { - $this->status['pass'] = ''; + if (!$result) { + $this->testStatus->setTrue('fail_headers'); } else { - $this->status['fail'] = 'headers'; + $this->testStatus->setTrue('pass_headers'); } } @@ -226,10 +223,13 @@ class rtPhpTest { return $this->sections[$sectionKey]; } - + + /* + * Return the object containing all test status + */ public function getStatus() { - return $this->status; + return $this->testStatus; } public function getFileSection() diff --git a/src/testcase/rtTestResults.php b/src/testcase/rtTestResults.php index 2d15017..6431e1c 100644 --- a/src/testcase/rtTestResults.php +++ b/src/testcase/rtTestResults.php @@ -19,46 +19,44 @@ */ class rtTestResults { - private $status = array(); + private $testStatus; private $testName = ''; private $savedResultsFiles = array(); private $title = ''; - public function __construct(rtPhpTest $testCase = null, $borkErrorString = null, $borkedFile = null) + public function __construct(rtPhpTest $testCase = null, rtTestStatus $testStatus = null) { - $this->init($testCase,$borkErrorString, $borkedFile); + $this->init($testCase, $testStatus); } - public function init(rtPhpTest $testCase = null, $borkErrorString = null, $borkedFile = null) + public function init(rtPhpTest $testCase = null, rtTestStatus $testStatus = null) { if ($testCase != null) { $this->title = implode('',$testCase->getSection('TEST')->getContents()); - $this->status = $testCase->getStatus(); + $this->testStatus = $testCase->getStatus(); $this->testName = $testCase->getName(); } else { - $this->status['bork'] = $borkErrorString; - $this->testName = $borkedFile; + $this->testStatus = $testStatus; + $this->testName = $testStatus->getTestName(); } } public function processResults(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - if (array_key_exists('pass', $this->status)) { + if ($testCase->getStatus()->getValue('pass') == true) { $this->onPass($testCase, $runConfiguration); - } elseif (array_key_exists('fail', $this->status)) { + } elseif($testCase->getStatus()->getValue('fail') == true) { $this->onFail($testCase); - } elseif (array_key_exists('skip', $this->status)) { + } elseif ($testCase->getStatus()->getValue('skip') == true) { $this->onSkip($testCase, $runConfiguration); - } elseif (array_key_exists('bork', $this->status)) { - //what to do here? } else { echo "no status? something wrong here\n"; } } /** - * Actions is a test passes + * Actions if a test passes */ private function onPass(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { @@ -81,7 +79,8 @@ class rtTestResults } if ($testCase->hasSection('XFAIL')) { - $this->status['warn'] = 'Test passeses but has an XFAIL section'; + $this->testStatus->setTrue('warn'); + $this->testStatus->setMessage('warn', 'Test passes but has an XFAIL section'); } if ($testCase->hasSection('CLEAN')) { @@ -115,7 +114,9 @@ class rtTestResults $this->savedFileNames['diff'] = $differenceFileName; if ($testCase->hasSection('XFAIL')) { - $this->status['xfail'] = $testCase->getSection('XFAIL')->getReason(); + $this->testStatus->setTrue('xfail'); + $this->testStatus->setMessage('xfail', $testCase->getSection('XFAIL')->getReason()); + } //Note: if there are clean and skipif files they will not be deleted if the test fails @@ -141,13 +142,14 @@ class rtTestResults //a few windows tests with blank XFAIL sections and wanted to know about those. if ($testCase->hasSection('XFAIL')) { - $this->status['xfail'] = $testCase->getSection('XFAIL')->getReason(); + $this->testStatus->setTrue('xfail'); + $this->testStatus->setMessage('xfail',$testCase->getSection('XFAIL')->getReason()); } } public function getStatus() { - return $this->status; + return $this->testStatus; } public function getSavedFileNames() diff --git a/src/testcase/rtTestStatus.php b/src/testcase/rtTestStatus.php index e5b4693..411c666 100644 --- a/src/testcase/rtTestStatus.php +++ b/src/testcase/rtTestStatus.php @@ -13,5 +13,66 @@ * */ class rtTestStatus { + + private $testName; + private $states = array(); + private $messages = array(); + private $stateName = array ('skip', + 'bork', + 'warn', + 'xfail', + 'fail', + 'pass', + 'fail_clean', + 'fail_skip', + 'fail_headers', + 'pass_headers', + ); + + public function __construct() + { + $this->init(); + } + + private function init() + { + foreach ($this->stateName as $name) { + $this->states[$name] = false; + $this->messages[$name] = ''; + } + } + + public function setTrue($name) + { + $this->states[$name] = true; + } + + public function setMessage($name, $text) + { + $this->messages[$name] = $text; + } + + public function getValue($name) + { + return $this->states[$name]; + } + + public function getMessage($name) + { + return $this->messages[$name]; + } + + public function getName() { + return $this->stateName; + } + + public function setTestName($name) { + $this->testName = $name; + } + + public function getTestName() { + return $this->testName; + } + } ?> \ No newline at end of file diff --git a/src/testcase/sections/executablesections/rtCleanSection.php b/src/testcase/sections/executablesections/rtCleanSection.php index 54c4243..ace4959 100644 --- a/src/testcase/sections/executablesections/rtCleanSection.php +++ b/src/testcase/sections/executablesections/rtCleanSection.php @@ -21,7 +21,7 @@ class rtCleanSection extends rtExecutableSection public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - $this->status = array(); + $testStatus = $testCase->getStatus(); $this->setExecutableFileName($testCase->getName()); $this->writeExecutableFile(); @@ -39,13 +39,16 @@ class rtCleanSection extends rtExecutableSection $this->output = $PhpRunner->runphp(); //if the CLEAN section has worked the result should be a blank line if (trim($this->output) != "") { - $this->status['warn'] = 'Execution of clean section failed: '.trim($this->output); + $testStatus->setTrue('fail_clean'); + $testStatus->setMessage('fail_clean','Execution of clean section failed: '.trim($this->output) ); + } } catch (rtPhpRunnerException $e) { - $this->status['warn'] = 'Failed to execute clean section'; + $testStatus->setTrue('fail_clean'); + $testStatus->setMessage('fail_clean',$e->getMessage); } - return $this->status; + return $testStatus; } } ?> diff --git a/src/testcase/sections/executablesections/rtFileExternalSection.php b/src/testcase/sections/executablesections/rtFileExternalSection.php index 8df5dc7..fcda80e 100644 --- a/src/testcase/sections/executablesections/rtFileExternalSection.php +++ b/src/testcase/sections/executablesections/rtFileExternalSection.php @@ -21,20 +21,22 @@ class rtFileExternalSection extends rtFileSection */ public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - if ($this->copyExternalFileContent() === true) { + $testStatus = $this->copyExternalFileContent($testCase->getStatus()); + if ($testStatus->getValue('fail') == false) { return parent::run($testCase, $runConfiguration); } - return $this->status; + return $testStatus; } /** * @return boolean */ - private function copyExternalFileContent() + private function copyExternalFileContent($testStatus) { if (sizeof($this->sectionContents) != 1) { - $this->status['fail'] = 'One file per testcase permitted.'; - return false; + $this->testStatus->setTrue('fail'); + $this->testStatus->setMessage('fail', 'One file per testcase permitted.'); + return $testStatus; } $file = $this->sectionContents[0]; @@ -43,12 +45,13 @@ class rtFileExternalSection extends rtFileSection $file = dirname($this->fileName).'/'.trim(str_replace('..', '', $file)); if (!file_exists($file)) { - $this->status['fail'] = 'Can not open external file '.$file; - return false; + $testStatus->setTrue('fail'); + $testStatus->setMessage('fail', 'Can not open external file '.$file ); + return $testStatus; } $this->sectionContents[0] = file_get_contents($file); - return true; + return $this->testStatus; } public function writeExecutableFile() { diff --git a/src/testcase/sections/executablesections/rtFileSection.php b/src/testcase/sections/executablesections/rtFileSection.php index 40883ff..dc3f7b5 100644 --- a/src/testcase/sections/executablesections/rtFileSection.php +++ b/src/testcase/sections/executablesections/rtFileSection.php @@ -27,15 +27,16 @@ class rtFileSection extends rtExecutableSection public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - $this->status = array(); + $testStatus = $testCase->getStatus(); $this->writeExecutableFile(); $phpExecutable = $testCase->testConfiguration->getPhpExecutable(); // The CGI excutable is null if it is not available, check and SKIP if necessary if (is_null($phpExecutable)) { - $this->status['skip'] = 'The CGI executable is unavailable'; - return $this->status; + $testStatus->setTrue('skip'); + $testStatus->setMessage('skip', 'The CGI executable is unavailable' ); + return $testStatus; } @@ -67,10 +68,11 @@ class rtFileSection extends rtExecutableSection } catch (rtPhpRunnerException $e) { - $this->status['fail'] = $e->getMessage(); + $testStatus->setTrue('fail'); + $testStatus->setMessage('fail', $e->getMessage() ); } - return $this->status; + return $testStatus; } /** diff --git a/src/testcase/sections/executablesections/rtSkipIfSection.php b/src/testcase/sections/executablesections/rtSkipIfSection.php index 20a1094..44276e1 100644 --- a/src/testcase/sections/executablesections/rtSkipIfSection.php +++ b/src/testcase/sections/executablesections/rtSkipIfSection.php @@ -21,8 +21,8 @@ class rtSkipIfSection extends rtExecutableSection public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration) { - $this->status = array(); + $testStatus = $testCase->getStatus(); $this->setExecutableFileName($testCase->getName()); $this->writeExecutableFile(); @@ -39,25 +39,24 @@ class rtSkipIfSection extends rtExecutableSection $this->output = $PhpRunner->runphp(); if (!strncasecmp('skip', ltrim($this->output), 4)) { - if (preg_match('/^\s*skip\s*(.+)\s*/i', $this->output, $matches)) { - $this->status['skip'] = $matches[1]; - } else { - $this->status['skip'] = ''; + $testStatus->setTrue('skip'); + if (preg_match('/^\s*skip\s*(.+)\s*/i', $this->output, $matches)) { + $testStatus->setMessage('skip', $matches[1]); } } if (!strncasecmp('warn', ltrim($this->output), 4)) { + $testStatus->setTrue('warn'); if (preg_match('/^\s*warn\s*(.+)\s*/i', $this->output, $matches)) { - $this->status['warn'] = $matches[1]; - } else { - $this->status['warn'] = ''; + $testStatus->setMessage('warn', $matches[1]); } } } catch (rtPhpRunnerException $e) { - $this->status['bork'] = 'Failed to execute skipif section'; + $testStatus->setTrue('fail_skip'); + $testStatus->setMessage('fail_skip', 'Failed to execute skipif section' . $e->getMessage()); } - return $this->status; + return $testStatus; } } ?> diff --git a/src/testgroup/rtPhpTestGroup.php b/src/testgroup/rtPhpTestGroup.php index b611f49..e196bac 100644 --- a/src/testgroup/rtPhpTestGroup.php +++ b/src/testgroup/rtPhpTestGroup.php @@ -40,11 +40,16 @@ class rtPhpTestGroup $testFile->doRead($testName); $testFile->normaliseLineEndings(); + $testStatus = new rtTestStatus(); + $testStatus->setTestName($testFile->getTestName()); if ($testFile->arePreconditionsMet() ) { // Create a new test case - $this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration); + + $this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus); } else { - $this->results[] = new rtTestResults(null, $testFile->getExitMessage(), $testFile->getTestName()); + $testStatus->setTrue('bork'); + $testStatus->setMessage('bork', $testFile->getExitMessage()); + $this->results[] = new rtTestResults(null, $testStatus); } } } diff --git a/tests/testcase/rtCleanExecutionTest.php b/tests/testcase/rtCleanExecutionTest.php index 3a79517..0d91718 100644 --- a/tests/testcase/rtCleanExecutionTest.php +++ b/tests/testcase/rtCleanExecutionTest.php @@ -44,11 +44,11 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case - $testCase->executeTest($config); + $status = $testCase->executeTest($config); //Check that the temp file has been removed $fileName = $this->path_to_tests . '/phpt-tests/cleantest.tmp'; - + $this->assertFalse($testCase->getStatus()->getValue('fail_clean')); $this->assertFalse(file_exists($fileName)); } @@ -75,7 +75,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase //Check that the temp file has been removed $fileName = $this->path_to_tests . '/cleantest.tmp'; - + $this->assertTrue($testCase->getStatus()->getValue('fail_clean')); $this->assertTrue(file_exists($fileName)); } } diff --git a/tests/testcase/rtCookieExecutionTest.php b/tests/testcase/rtCookieExecutionTest.php index 611ffab..d23e167 100644 --- a/tests/testcase/rtCookieExecutionTest.php +++ b/tests/testcase/rtCookieExecutionTest.php @@ -45,10 +45,7 @@ class rtCookieExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); - $status = $testCase->getStatus(); - - $this->assertEquals('', $status['pass']); - + $this->assertFalse($testCase->getStatus()->getValue('fail')); } } diff --git a/tests/testcase/rtDeflatePostExecutionTest.php b/tests/testcase/rtDeflatePostExecutionTest.php index b9618b1..f42b46a 100644 --- a/tests/testcase/rtDeflatePostExecutionTest.php +++ b/tests/testcase/rtDeflatePostExecutionTest.php @@ -43,10 +43,11 @@ class rtDeflatePostExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); $output = $testCase->getOutput(); - $status = $testCase->getStatus(); + $this->assertEquals('It worked!', trim($output)); - $this->assertEquals('', $status['pass']); + $this->assertFalse($testCase->getStatus()->getValue('fail')); + } diff --git a/tests/testcase/rtExpectHeadersExecutionTest.php b/tests/testcase/rtExpectHeadersExecutionTest.php index 9e1cd34..6270f97 100644 --- a/tests/testcase/rtExpectHeadersExecutionTest.php +++ b/tests/testcase/rtExpectHeadersExecutionTest.php @@ -46,12 +46,11 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); - $output = $testCase->getOutput(); - $stat = $testCase->getStatus(); - $headers = $testCase->getHeaders(); + + - - $this->assertEquals('', $stat['pass']); + $this->assertFalse($testCase->getStatus()->getValue('fail_headers')); + } @@ -76,9 +75,10 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); - $stat = $testCase->getStatus(); - - $this->assertEquals('headers', $stat['fail']); + + + $this->assertTrue($testCase->getStatus()->getValue('fail_headers')); + } } diff --git a/tests/testcase/rtGetExecutionTest.php b/tests/testcase/rtGetExecutionTest.php index 5019f8d..d33217d 100644 --- a/tests/testcase/rtGetExecutionTest.php +++ b/tests/testcase/rtGetExecutionTest.php @@ -48,7 +48,7 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $status = $testCase->getStatus(); $this->assertEquals('85', strlen($output)); - $this->assertEquals('', $status['pass']); + $this->assertFalse($testCase->getStatus()->getValue('fail')); } @@ -81,7 +81,8 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $this->assertEquals(0, strlen($output)); - $this->assertEquals('The CGI executable is unavailable', $status['skip']); + $this->assertTrue($testCase->getStatus()->getValue('skip')); + $this->assertEquals('The CGI executable is unavailable', $testCase->getStatus()->getMessage('skip')); } diff --git a/tests/testcase/rtGzipPostExecutionTest.php b/tests/testcase/rtGzipPostExecutionTest.php index 9b749f6..e7fb5c5 100644 --- a/tests/testcase/rtGzipPostExecutionTest.php +++ b/tests/testcase/rtGzipPostExecutionTest.php @@ -43,10 +43,11 @@ class rtGzipPostExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); $output = $testCase->getOutput(); - $status = $testCase->getStatus(); + $this->assertEquals('It worked!', trim($output)); - $this->assertEquals('', $status['pass']); + $this->assertFalse($testCase->getStatus()->getValue('fail')); + } diff --git a/tests/testcase/rtPostExecutionTest.php b/tests/testcase/rtPostExecutionTest.php index c168d6e..c826bcf 100644 --- a/tests/testcase/rtPostExecutionTest.php +++ b/tests/testcase/rtPostExecutionTest.php @@ -43,11 +43,10 @@ class rtPostExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); $output = $testCase->getOutput(); - $status = $testCase->getStatus(); - $this->assertEquals('85', strlen($output)); - $this->assertEquals('', $status['pass']); + $this->assertEquals('85', strlen($output)); + $this->assertFalse($testCase->getStatus()->getValue('fail')); } } diff --git a/tests/testcase/rtPostRawExecutionTest.php b/tests/testcase/rtPostRawExecutionTest.php index 60d7edf..b7bf8b3 100644 --- a/tests/testcase/rtPostRawExecutionTest.php +++ b/tests/testcase/rtPostRawExecutionTest.php @@ -43,10 +43,9 @@ class rtPostRawExecutionTest extends PHPUnit_Framework_TestCase //Setup and set the local environment for the test case $testCase->executeTest($config); - $status = $testCase->getStatus(); - - //$this->assertEquals('It worked!', trim($output)); - $this->assertEquals('', $status['pass']); + + $this->assertFalse($testCase->getStatus()->getValue('fail')); + } diff --git a/tests/testcase/rtSkipIfExecutionTest.php b/tests/testcase/rtSkipIfExecutionTest.php index 2dda29a..dccc29b 100644 --- a/tests/testcase/rtSkipIfExecutionTest.php +++ b/tests/testcase/rtSkipIfExecutionTest.php @@ -41,7 +41,8 @@ class rtSkipIfExecutionTest extends PHPUnit_Framework_TestCase $testCase->executeTest($config); //Check that the test has been skipped - $this->assertTrue(array_key_exists('skip', $testCase->getStatus())); + //var_dump($testCase->getStatus()); + $this->assertTrue($testCase->getStatus()->getValue('skip')); } } ?> diff --git a/tests/testcase/rtTestExecutionTest.php b/tests/testcase/rtTestExecutionTest.php index 11e5ba1..531325f 100644 --- a/tests/testcase/rtTestExecutionTest.php +++ b/tests/testcase/rtTestExecutionTest.php @@ -104,7 +104,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testCase->compareOutput(); //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); + $this->assertFalse($testCase->getStatus()->getValue('fail')); } public function testExpectFFileRunAndCompare() @@ -132,7 +132,8 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testCase->compareOutput(); //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); + $this->assertFalse($testCase->getStatus()->getValue('fail')); + } public function testExpectRegexFileRunAndCompare() @@ -160,7 +161,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testCase->compareOutput(); //Check the exit status - $this->assertTrue(array_key_exists('pass', $testCase->getStatus())); + $this->assertFalse($testCase->getStatus()->getValue('fail_clean')); } } ?> diff --git a/tests/testcase/rtTestResultsTest.php b/tests/testcase/rtTestResultsTest.php index 8b84e67..7530b22 100644 --- a/tests/testcase/rtTestResultsTest.php +++ b/tests/testcase/rtTestResultsTest.php @@ -233,8 +233,9 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $results = new rtTestResults($testCase); $results->processResults($testCase, $config); + + $this->assertTrue($testCase->getStatus()->getValue('pass')); - $this->assertTrue(array_key_exists('pass', $results->getStatus())); } public function testBork() @@ -252,10 +253,13 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); if (!$testFile->arePreConditionsMet()) { + $testStatus = new rtTestStatus(); + $testStatus->setTrue('bork'); + $testStatus->setMessage('bork', 'bork message'); - $results = new rtTestResults(null, "borked", $testFiles[0]); + $results = new rtTestResults( null, $testStatus); - $this->assertTrue(array_key_exists('bork', $results->getStatus())); + $this->assertTrue($results->getStatus()->getvalue('bork')); } } } diff --git a/tests/testcase/rtTestStatusTest.php b/tests/testcase/rtTestStatusTest.php new file mode 100644 index 0000000..b51dc59 --- /dev/null +++ b/tests/testcase/rtTestStatusTest.php @@ -0,0 +1,12 @@ +<?php +require_once 'PHPUnit/Framework.php'; +require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; + +class rtTestStatusTest extends PHPUnit_Framework_TestCase { + function testCreate() + { + $status = new rtTestStatus(); + $this->assertFalse($status->getValue('skip')); + } +} +?> \ No newline at end of file diff --git a/tests/testcase/sections/executablesections/rtFileSectionTest.php b/tests/testcase/sections/executablesections/rtFileSectionTest.php index 1315d14..1a03da9 100644 --- a/tests/testcase/sections/executablesections/rtFileSectionTest.php +++ b/tests/testcase/sections/executablesections/rtFileSectionTest.php @@ -12,22 +12,5 @@ class rtFileSectionTest extends PHPUnit_Framework_TestCase $this->assertEquals('<?php', $code[0]); } - public function testDone() - { - $fileSection = rtFileSection::getInstance('FILE', array('<?php', 'echo "hello world";', '?>', '===DONE===', 'ignore-me')); - $code = $fileSection->getContents(); - $last = count($code) - 1; - - $this->assertEquals('===DONE===', $code[$last]); - } - - public function testDone2() - { - $fileSection = rtFileSection::getInstance('FILE', array('<?php', 'echo "hello world";', '?>', '===DoNe===', 'ignore-me')); - $code = $fileSection->getContents(); - $last = count($code) - 1; - - $this->assertEquals('===DoNe===', $code[$last]); - } } ?>
« previous php.qa (#66428) next »