com phpruntests: move name to constructor in testStatus: src/testcase/output/rtTestOutputWriterList.php src/testcase/rtTestDifference.php
src/testcase/rtTestStatus.php src/testgroup/rtPhpTestGroup.php src/testrun/rtPhpTestRun.php tests/testcase/rtCleanExecutionTest.php
tests/testcase/rtCookieExecutionTest.php tests/testcase/rtDeflatePostExecutionTest.php tests/testcase/rtExpectHeadersExecutionTest.php
tests/testcase/rtGetExecutionTest.php tests/t
| From: | David Soria Parra | Date: | Sun, 07 Jun 2009 11:07:33 +0000 |
| Subject: | com phpruntests: move name to constructor in testStatus: src/testcase/output/rtTestOutputWriterList.php src/testcase/rtTestDifference.php src/testcase/rtTestStatus.php src/testgroup/rtPhpTestGroup.php src/testrun/rtPhpTestRun.php tests/testcase/rtCleanExecutionTest.php tests/testcase/rtCookieExecutionTest.php tests/testcase/rtDeflatePostExecutionTest.php tests/testcase/rtExpectHeadersExecutionTest.php tests/testcase/rtGetExecutionTest.php tests/t |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66424@lists.php.net to get a copy of this message | ||
Commit: f1bc00985a3bcbc1e54b705480b549c0409dd890
Author: Zoe Slattery <zoe@php.net> Sun, 7 Jun 2009 11:07:33 +0000
Parents: 345fcdbbba9def2d9bfe25bfa7d61a8540d38ab5
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=f1bc00985a3bcbc1e54b705480b549c0409dd890
Log:
move name to constructor in testStatus
Changed paths:
M src/testcase/output/rtTestOutputWriterList.php
M src/testcase/rtTestDifference.php
M src/testcase/rtTestStatus.php
M src/testgroup/rtPhpTestGroup.php
M src/testrun/rtPhpTestRun.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/rtPhpTestTest.php
M tests/testcase/rtPostExecutionTest.php
M tests/testcase/rtPostRawExecutionTest.php
M tests/testcase/rtSkipIfExecutionTest.php
M tests/testcase/rtTestExecutionTest..php
M tests/testcase/rtTestOutputWriterTest.php
M tests/testcase/rtTestResultsTest.php
M tests/testcase/rtTestStatusTest.php
diff --git a/src/testcase/output/rtTestOutputWriterList.php b/src/testcase/output/rtTestOutputWriterList.php index 7fe7965..4a89859 100644 --- a/src/testcase/output/rtTestOutputWriterList.php +++ b/src/testcase/output/rtTestOutputWriterList.php @@ -33,7 +33,7 @@ class rtTestOutputWriterList extends rtTestOutputWriter foreach ($testResults as $testResult) { $outputString = ""; $testStatus = $testResult->getStatus(); - foreach($testStatus->getName() as $name) { + foreach($testStatus->getTestStateNames() as $name) { if($testStatus->getValue($name)) { $outputString .= " ". strtoupper($name); $outputString .= " " . $testStatus->getMessage($name); diff --git a/src/testcase/rtTestDifference.php b/src/testcase/rtTestDifference.php index 6570599..1104791 100644 --- a/src/testcase/rtTestDifference.php +++ b/src/testcase/rtTestDifference.php @@ -62,7 +62,6 @@ class rtTestDifference */ public function generateArrayDiff($ar1, $ar2, $is_reg, $w) { - var_dump($is_reg); file_put_contents("/home/zoe/bug/ar1_my.out", $ar1); file_put_contents("/home/zoe/bug/ar2_my.out", $ar2); @@ -204,8 +203,6 @@ class rtTestDifference public function compLine($l1, $l2, $is_reg) { if ($is_reg) { - /* var_dump($l1); - var_dump($l2);*/ return preg_match((binary) "/^$l1$/s", (binary) $l2); } else { return !strcmp((binary) $l1, (binary) $l2); diff --git a/src/testcase/rtTestStatus.php b/src/testcase/rtTestStatus.php index 411c666..2dbfa4d 100644 --- a/src/testcase/rtTestStatus.php +++ b/src/testcase/rtTestStatus.php @@ -17,7 +17,7 @@ class rtTestStatus { private $testName; private $states = array(); private $messages = array(); - private $stateName = array ('skip', + private $testStateNames = array ('skip', 'bork', 'warn', 'xfail', @@ -29,14 +29,15 @@ class rtTestStatus { 'pass_headers', ); - public function __construct() + public function __construct($testName) { + $this->testName = $testName; $this->init(); } private function init() { - foreach ($this->stateName as $name) { + foreach ($this->testStateNames as $name) { $this->states[$name] = false; $this->messages[$name] = ''; } @@ -62,12 +63,8 @@ class rtTestStatus { return $this->messages[$name]; } - public function getName() { - return $this->stateName; - } - - public function setTestName($name) { - $this->testName = $name; + public function getTestStateNames() { + return $this->testStateNames; } public function getTestName() { diff --git a/src/testgroup/rtPhpTestGroup.php b/src/testgroup/rtPhpTestGroup.php index e196bac..ef0dfcc 100644 --- a/src/testgroup/rtPhpTestGroup.php +++ b/src/testgroup/rtPhpTestGroup.php @@ -28,20 +28,25 @@ class rtPhpTestGroup { $this->testFiles = rtUtil::getTestList($this->testDirectory); - foreach ($this->testFiles as $testName) { + foreach ($this->testFiles as $testFileName) { + + //testFiles is a list of file namnes relative to the current working directory - if (!file_exists($testName)) { - echo rtText::get('invalidTestFileName', array($testName)); + if (!file_exists($testFileName)) { + echo rtText::get('invalidTestFileName', array($testFileName)); exit(); } // Create a new test file object; $testFile = new rtPhpTestFile(); - $testFile->doRead($testName); + $testFile->doRead($testFileName); $testFile->normaliseLineEndings(); + + //The test name is the full path to the test file name without the .phpt - $testStatus = new rtTestStatus(); - $testStatus->setTestName($testFile->getTestName()); + $testStatus = new rtTestStatus($testFile->getTestName()); + echo $testFile->getTestName() . "\n"; + if ($testFile->arePreconditionsMet() ) { // Create a new test case diff --git a/src/testrun/rtPhpTestRun.php b/src/testrun/rtPhpTestRun.php index 429ca89..0937dd2 100644 --- a/src/testrun/rtPhpTestRun.php +++ b/src/testrun/rtPhpTestRun.php @@ -89,8 +89,8 @@ class rtPhpTestRun $testFile->doRead($testName); $testFile->normaliseLineEndings($testName); - $testStatus = new rtTestStatus(); - $testStatus->setTestName($testFile->getTestName()); + $testStatus = new rtTestStatus($testFile->getTestName()); + if ($testFile->arePreconditionsMet()) { diff --git a/tests/testcase/rtCleanExecutionTest.php b/tests/testcase/rtCleanExecutionTest.php index 0d91718..da10eda 100644 --- a/tests/testcase/rtCleanExecutionTest.php +++ b/tests/testcase/rtCleanExecutionTest.php @@ -40,7 +40,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -67,7 +67,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtCookieExecutionTest.php b/tests/testcase/rtCookieExecutionTest.php index d23e167..7e579b2 100644 --- a/tests/testcase/rtCookieExecutionTest.php +++ b/tests/testcase/rtCookieExecutionTest.php @@ -39,7 +39,7 @@ class rtCookieExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtDeflatePostExecutionTest.php b/tests/testcase/rtDeflatePostExecutionTest.php index f42b46a..12efd41 100644 --- a/tests/testcase/rtDeflatePostExecutionTest.php +++ b/tests/testcase/rtDeflatePostExecutionTest.php @@ -37,7 +37,7 @@ class rtDeflatePostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtExpectHeadersExecutionTest.php b/tests/testcase/rtExpectHeadersExecutionTest.php index 6270f97..c9050a0 100644 --- a/tests/testcase/rtExpectHeadersExecutionTest.php +++ b/tests/testcase/rtExpectHeadersExecutionTest.php @@ -41,7 +41,7 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -70,7 +70,7 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtGetExecutionTest.php b/tests/testcase/rtGetExecutionTest.php index d33217d..78eb2e4 100644 --- a/tests/testcase/rtGetExecutionTest.php +++ b/tests/testcase/rtGetExecutionTest.php @@ -39,7 +39,7 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -69,7 +69,7 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtGzipPostExecutionTest.php b/tests/testcase/rtGzipPostExecutionTest.php index e7fb5c5..9630aeb 100644 --- a/tests/testcase/rtGzipPostExecutionTest.php +++ b/tests/testcase/rtGzipPostExecutionTest.php @@ -37,7 +37,7 @@ class rtGzipPostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtPhpTestTest.php b/tests/testcase/rtPhpTestTest.php index 31d27f0..a96dbca 100644 --- a/tests/testcase/rtPhpTestTest.php +++ b/tests/testcase/rtPhpTestTest.php @@ -27,7 +27,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); $this->assertEquals('rtPhpTest', get_class($test)); @@ -38,7 +38,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); $this->assertEquals('rtTestHeaderSection', get_class($test->getSection('TEST'))); @@ -51,7 +51,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); // var_dump($test->getSection('FILE')); diff --git a/tests/testcase/rtPostExecutionTest.php b/tests/testcase/rtPostExecutionTest.php index c826bcf..8420064 100644 --- a/tests/testcase/rtPostExecutionTest.php +++ b/tests/testcase/rtPostExecutionTest.php @@ -37,7 +37,7 @@ class rtPostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtPostRawExecutionTest.php b/tests/testcase/rtPostRawExecutionTest.php index b7bf8b3..385836b 100644 --- a/tests/testcase/rtPostRawExecutionTest.php +++ b/tests/testcase/rtPostRawExecutionTest.php @@ -37,7 +37,7 @@ class rtPostRawExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtSkipIfExecutionTest.php b/tests/testcase/rtSkipIfExecutionTest.php index dccc29b..d11490b 100644 --- a/tests/testcase/rtSkipIfExecutionTest.php +++ b/tests/testcase/rtSkipIfExecutionTest.php @@ -34,7 +34,7 @@ class rtSkipIfExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestExecutionTest.php b/tests/testcase/rtTestExecutionTest.php index 531325f..3e6f94e 100644 --- a/tests/testcase/rtTestExecutionTest.php +++ b/tests/testcase/rtTestExecutionTest.php @@ -44,7 +44,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -69,7 +69,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -94,7 +94,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -122,7 +122,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -151,7 +151,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestOutputWriterTest.php b/tests/testcase/rtTestOutputWriterTest.php index 9d5045a..fd9cb2c 100644 --- a/tests/testcase/rtTestOutputWriterTest.php +++ b/tests/testcase/rtTestOutputWriterTest.php @@ -42,7 +42,7 @@ class rtTestOutputWriterTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestResultsTest.php b/tests/testcase/rtTestResultsTest.php index 7530b22..7fc96d3 100644 --- a/tests/testcase/rtTestResultsTest.php +++ b/tests/testcase/rtTestResultsTest.php @@ -45,7 +45,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -74,7 +74,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -103,7 +103,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -132,7 +132,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -164,7 +164,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -194,7 +194,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -223,7 +223,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -253,7 +253,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); if (!$testFile->arePreConditionsMet()) { - $testStatus = new rtTestStatus(); + $testStatus = new rtTestStatus($testFile->getTestName()); $testStatus->setTrue('bork'); $testStatus->setMessage('bork', 'bork message'); diff --git a/tests/testcase/rtTestStatusTest.php b/tests/testcase/rtTestStatusTest.php index b51dc59..08c7790 100644 --- a/tests/testcase/rtTestStatusTest.php +++ b/tests/testcase/rtTestStatusTest.php @@ -5,7 +5,8 @@ require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; class rtTestStatusTest extends PHPUnit_Framework_TestCase { function testCreate() { - $status = new rtTestStatus(); + $status = new rtTestStatus('aTest'); + $this->assertEquals('aTest', $status->getTestName()); $this->assertFalse($status->getValue('skip')); } }
diff --git a/src/testcase/output/rtTestOutputWriterList.php b/src/testcase/output/rtTestOutputWriterList.php index 7fe7965..4a89859 100644 --- a/src/testcase/output/rtTestOutputWriterList.php +++ b/src/testcase/output/rtTestOutputWriterList.php @@ -33,7 +33,7 @@ class rtTestOutputWriterList extends rtTestOutputWriter foreach ($testResults as $testResult) { $outputString = ""; $testStatus = $testResult->getStatus(); - foreach($testStatus->getName() as $name) { + foreach($testStatus->getTestStateNames() as $name) { if($testStatus->getValue($name)) { $outputString .= " ". strtoupper($name); $outputString .= " " . $testStatus->getMessage($name); diff --git a/src/testcase/rtTestDifference.php b/src/testcase/rtTestDifference.php index 6570599..1104791 100644 --- a/src/testcase/rtTestDifference.php +++ b/src/testcase/rtTestDifference.php @@ -62,7 +62,6 @@ class rtTestDifference */ public function generateArrayDiff($ar1, $ar2, $is_reg, $w) { - var_dump($is_reg); file_put_contents("/home/zoe/bug/ar1_my.out", $ar1); file_put_contents("/home/zoe/bug/ar2_my.out", $ar2); @@ -204,8 +203,6 @@ class rtTestDifference public function compLine($l1, $l2, $is_reg) { if ($is_reg) { - /* var_dump($l1); - var_dump($l2);*/ return preg_match((binary) "/^$l1$/s", (binary) $l2); } else { return !strcmp((binary) $l1, (binary) $l2); diff --git a/src/testcase/rtTestStatus.php b/src/testcase/rtTestStatus.php index 411c666..2dbfa4d 100644 --- a/src/testcase/rtTestStatus.php +++ b/src/testcase/rtTestStatus.php @@ -17,7 +17,7 @@ class rtTestStatus { private $testName; private $states = array(); private $messages = array(); - private $stateName = array ('skip', + private $testStateNames = array ('skip', 'bork', 'warn', 'xfail', @@ -29,14 +29,15 @@ class rtTestStatus { 'pass_headers', ); - public function __construct() + public function __construct($testName) { + $this->testName = $testName; $this->init(); } private function init() { - foreach ($this->stateName as $name) { + foreach ($this->testStateNames as $name) { $this->states[$name] = false; $this->messages[$name] = ''; } @@ -62,12 +63,8 @@ class rtTestStatus { return $this->messages[$name]; } - public function getName() { - return $this->stateName; - } - - public function setTestName($name) { - $this->testName = $name; + public function getTestStateNames() { + return $this->testStateNames; } public function getTestName() { diff --git a/src/testgroup/rtPhpTestGroup.php b/src/testgroup/rtPhpTestGroup.php index e196bac..ef0dfcc 100644 --- a/src/testgroup/rtPhpTestGroup.php +++ b/src/testgroup/rtPhpTestGroup.php @@ -28,20 +28,25 @@ class rtPhpTestGroup { $this->testFiles = rtUtil::getTestList($this->testDirectory); - foreach ($this->testFiles as $testName) { + foreach ($this->testFiles as $testFileName) { + + //testFiles is a list of file namnes relative to the current working directory - if (!file_exists($testName)) { - echo rtText::get('invalidTestFileName', array($testName)); + if (!file_exists($testFileName)) { + echo rtText::get('invalidTestFileName', array($testFileName)); exit(); } // Create a new test file object; $testFile = new rtPhpTestFile(); - $testFile->doRead($testName); + $testFile->doRead($testFileName); $testFile->normaliseLineEndings(); + + //The test name is the full path to the test file name without the .phpt - $testStatus = new rtTestStatus(); - $testStatus->setTestName($testFile->getTestName()); + $testStatus = new rtTestStatus($testFile->getTestName()); + echo $testFile->getTestName() . "\n"; + if ($testFile->arePreconditionsMet() ) { // Create a new test case diff --git a/src/testrun/rtPhpTestRun.php b/src/testrun/rtPhpTestRun.php index 429ca89..0937dd2 100644 --- a/src/testrun/rtPhpTestRun.php +++ b/src/testrun/rtPhpTestRun.php @@ -89,8 +89,8 @@ class rtPhpTestRun $testFile->doRead($testName); $testFile->normaliseLineEndings($testName); - $testStatus = new rtTestStatus(); - $testStatus->setTestName($testFile->getTestName()); + $testStatus = new rtTestStatus($testFile->getTestName()); + if ($testFile->arePreconditionsMet()) { diff --git a/tests/testcase/rtCleanExecutionTest.php b/tests/testcase/rtCleanExecutionTest.php index 0d91718..da10eda 100644 --- a/tests/testcase/rtCleanExecutionTest.php +++ b/tests/testcase/rtCleanExecutionTest.php @@ -40,7 +40,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -67,7 +67,7 @@ class rtCleanExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtCookieExecutionTest.php b/tests/testcase/rtCookieExecutionTest.php index d23e167..7e579b2 100644 --- a/tests/testcase/rtCookieExecutionTest.php +++ b/tests/testcase/rtCookieExecutionTest.php @@ -39,7 +39,7 @@ class rtCookieExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtDeflatePostExecutionTest.php b/tests/testcase/rtDeflatePostExecutionTest.php index f42b46a..12efd41 100644 --- a/tests/testcase/rtDeflatePostExecutionTest.php +++ b/tests/testcase/rtDeflatePostExecutionTest.php @@ -37,7 +37,7 @@ class rtDeflatePostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtExpectHeadersExecutionTest.php b/tests/testcase/rtExpectHeadersExecutionTest.php index 6270f97..c9050a0 100644 --- a/tests/testcase/rtExpectHeadersExecutionTest.php +++ b/tests/testcase/rtExpectHeadersExecutionTest.php @@ -41,7 +41,7 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -70,7 +70,7 @@ class rtExpectHeadersExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtGetExecutionTest.php b/tests/testcase/rtGetExecutionTest.php index d33217d..78eb2e4 100644 --- a/tests/testcase/rtGetExecutionTest.php +++ b/tests/testcase/rtGetExecutionTest.php @@ -39,7 +39,7 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -69,7 +69,7 @@ class rtGetExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtGzipPostExecutionTest.php b/tests/testcase/rtGzipPostExecutionTest.php index e7fb5c5..9630aeb 100644 --- a/tests/testcase/rtGzipPostExecutionTest.php +++ b/tests/testcase/rtGzipPostExecutionTest.php @@ -37,7 +37,7 @@ class rtGzipPostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtPhpTestTest.php b/tests/testcase/rtPhpTestTest.php index 31d27f0..a96dbca 100644 --- a/tests/testcase/rtPhpTestTest.php +++ b/tests/testcase/rtPhpTestTest.php @@ -27,7 +27,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); $this->assertEquals('rtPhpTest', get_class($test)); @@ -38,7 +38,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); $this->assertEquals('rtTestHeaderSection', get_class($test->getSection('TEST'))); @@ -51,7 +51,7 @@ class rtPhpTestTest extends PHPUnit_Framework_TestCase $config = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $this->php, 'test.phpt')); $config->configure(); - $status = new rtTestStatus(); + $status = new rtTestStatus('nameOfTest'); $test = new rtPhpTest($this->testCase, 'nameOfTest', array('TEST', 'FILE', 'EXPECTF'), $config, $status); // var_dump($test->getSection('FILE')); diff --git a/tests/testcase/rtPostExecutionTest.php b/tests/testcase/rtPostExecutionTest.php index c826bcf..8420064 100644 --- a/tests/testcase/rtPostExecutionTest.php +++ b/tests/testcase/rtPostExecutionTest.php @@ -37,7 +37,7 @@ class rtPostExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtPostRawExecutionTest.php b/tests/testcase/rtPostRawExecutionTest.php index b7bf8b3..385836b 100644 --- a/tests/testcase/rtPostRawExecutionTest.php +++ b/tests/testcase/rtPostRawExecutionTest.php @@ -37,7 +37,7 @@ class rtPostRawExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtSkipIfExecutionTest.php b/tests/testcase/rtSkipIfExecutionTest.php index dccc29b..d11490b 100644 --- a/tests/testcase/rtSkipIfExecutionTest.php +++ b/tests/testcase/rtSkipIfExecutionTest.php @@ -34,7 +34,7 @@ class rtSkipIfExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestExecutionTest.php b/tests/testcase/rtTestExecutionTest.php index 531325f..3e6f94e 100644 --- a/tests/testcase/rtTestExecutionTest.php +++ b/tests/testcase/rtTestExecutionTest.php @@ -44,7 +44,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -69,7 +69,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -94,7 +94,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -122,7 +122,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -151,7 +151,7 @@ class rtTestExecutionTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestOutputWriterTest.php b/tests/testcase/rtTestOutputWriterTest.php index 9d5045a..fd9cb2c 100644 --- a/tests/testcase/rtTestOutputWriterTest.php +++ b/tests/testcase/rtTestOutputWriterTest.php @@ -42,7 +42,7 @@ class rtTestOutputWriterTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case diff --git a/tests/testcase/rtTestResultsTest.php b/tests/testcase/rtTestResultsTest.php index 7530b22..7fc96d3 100644 --- a/tests/testcase/rtTestResultsTest.php +++ b/tests/testcase/rtTestResultsTest.php @@ -45,7 +45,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -74,7 +74,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -103,7 +103,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -132,7 +132,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -164,7 +164,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -194,7 +194,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -223,7 +223,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); //Create a new test case - $status = new rtTestStatus(); + $status = new rtTestStatus($testFile->getTestName()); $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $config, $status); //Setup and set the local environment for the test case @@ -253,7 +253,7 @@ class rtTestResultsTest extends PHPUnit_Framework_TestCase $testFile->normaliseLineEndings(); if (!$testFile->arePreConditionsMet()) { - $testStatus = new rtTestStatus(); + $testStatus = new rtTestStatus($testFile->getTestName()); $testStatus->setTrue('bork'); $testStatus->setMessage('bork', 'bork message'); diff --git a/tests/testcase/rtTestStatusTest.php b/tests/testcase/rtTestStatusTest.php index b51dc59..08c7790 100644 --- a/tests/testcase/rtTestStatusTest.php +++ b/tests/testcase/rtTestStatusTest.php @@ -5,7 +5,8 @@ require_once dirname(__FILE__) . '../../../src/rtAutoload.php'; class rtTestStatusTest extends PHPUnit_Framework_TestCase { function testCreate() { - $status = new rtTestStatus(); + $status = new rtTestStatus('aTest'); + $this->assertEquals('aTest', $status->getTestName()); $this->assertFalse($status->getValue('skip')); } }