Permalink
Browse files

Implementing REDIRECT TEST. Get list of testcases back to PhpRun class

  • Loading branch information...
1 parent 6232592 commit 24d08e775107faf433cff1a9f862994ecae7c028 zoe slattery committed May 20, 2012
View
@@ -80,6 +80,7 @@
'rtIniSection' => 'testcase/sections/configurationsections/rtIniSection.php',
'rtPostRawSection' => 'testcase/sections/configurationsections/rtPostRawSection.php',
'rtPostSection' => 'testcase/sections/configurationsections/rtPostSection.php',
+ 'rtRedirectSection' => 'testcase/sections/configurationsections/rtRedirectSection.php',
'rtStdinSection' => 'testcase/sections/configurationsections/rtStdinSection.php',
'rtCleanSection' => 'testcase/sections/executablesections/rtCleanSection.php',
'rtFileExternalSection' => 'testcase/sections/executablesections/rtFileExternalSection.php',
@@ -19,6 +19,7 @@ class rtTaskScheduler
protected $resultList = array(); // list of results
protected $processCount = 0; // the number of processes
protected $reportStatus = 0; // reprort-status
+ protected $redirectedTestCases = array();
/**
@@ -132,10 +133,15 @@ public function run()
$results = $task->getResult();
rtTestOutputWriter::flushResult($results, $this->reportStatus);
$this->resultList[] = $results;
+ $this->redirectedTestCases[] = $task->getRedirectedTestCases();
}
return;
}
+
+ public function getRedirectedTestCases() {
+ return $this->redirectedTestCases;
+ }
}
@@ -15,6 +15,7 @@ class rtTaskTestGroup extends rtTask implements rtTaskInterface
{
protected $runConfiguration;
protected $subDirectory;
+ protected $redirectedTestCases = array();
public function __construct($runConfiguration, $subDirectory)
@@ -33,8 +34,13 @@ public function run()
$testGroup = new rtPhpTestGroup($this->runConfiguration, $this->subDirectory);
$testGroup->runGroup($this->runConfiguration);
$this->result = $testGroup->getResults();
+ $this->redirectedTestCases = $testGroup->getRedirectedTestCases();
return true;
}
+
+ public function getRedirectedTestCases() {
+ return $this->redirectedTestCases;
+ }
}
@@ -42,7 +42,6 @@ class rtIsValidSectionName implements rtTestPreCondition
'GET',
'COOKIE',
'REDIRECTTEST',
- 'HEADERS',
'EXPECTHEADERS',
);
@@ -0,0 +1,11 @@
+<?php
+class rtRedirectSection extends rtConfigurationSection
+{
+
+ protected function init()
+ {
+
+ }
+
+}
+?>
@@ -38,6 +38,7 @@
'COOKIE' => 'rtCookieSection',
'FILE_EXTERNAL' => 'rtFileExternalSection',
'EXPECTHEADERS' => 'rtExpectHeadersSection',
+ 'REDIRECTTEST' => 'rtRedirectSection',
);
protected $sectionName;
@@ -58,9 +59,9 @@ protected function __construct($sectionName, $contents, $testName)
abstract protected function init();
public static function getInstance($sectionName, $contents, $testName)
- {
-
+ {
if (!isset(self::$sectionMap[$sectionName])) {
+ var_dump($testName);
throw new rtException('Unknown section type ' . $sectionName);
}
@@ -17,6 +17,7 @@ class rtPhpTestGroup
protected $testDirectory;
protected $testCases;
protected $results;
+ protected $redirectedTestCases = array();
public function __construct(rtRuntestsConfiguration $runConfiguration, $directory)
{
@@ -45,12 +46,13 @@ public function init(rtRuntestsConfiguration $runConfiguration)
//The test name is the full path to the test file name without the .phpt
$testStatus = new rtTestStatus($testFile->getTestName());
-
if ($testFile->arePreconditionsMet() ) {
- // Create a new test case
-
+ // Create a new test case
$this->testCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus);
- } else {
+ } elseif (in_array("REDIRECTTEST",$testFile->getSectionHeadings())){
+ //Redirect handler, save the test case for processing after the main groups have finished.
+ $this->redirectedTestCases[] = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus);
+ }else {
$testStatus->setTrue('bork');
$testStatus->setMessage('bork', $testFile->getExitMessage());
$this->results[] = new rtTestResults(null, $testStatus);
@@ -84,6 +86,10 @@ public function getResults()
{
return $this->results;
}
+
+ public function getRedirectedTestCases() {
+ return $this->redirectedTestCases;
+ }
}
?>
@@ -99,6 +99,16 @@ public function run()
$resultList = $scheduler->getResultList();
+ //Check to see if there are any redirected tests.
+
+ $redirects = $scheduler->getRedirectedTestCases();
+
+ for($i=0; $i<sizeof($subDirectories); $i++) {
+ foreach($redirects[$i] as $redirectedTestCase) {
+ echo "\nTest not executed, requires redirect. : ".$redirectedTestCase->getName();
+ }
+ }
+
// create output
$type = null;
if ($runConfiguration->hasCommandLineOption('o')) {
@@ -151,6 +161,13 @@ public function run()
$results = new rtTestResults($testCase);
$results->processResults($testCase, $runConfiguration);
+ } elseif (in_array("REDIRECTTEST", $testFile->getSectionHeadings())) {
+ //Redirect handler
+ $testCase = new rtPhpTest($testFile->getContents(), $testFile->getTestName(), $testFile->getSectionHeadings(), $runConfiguration, $testStatus);
+ echo "Not executed, will need to redirect: ".$testCase->getName()."\n";
+ $testStatus->setTrue('bork');
+ $testStatus->setMessage('bork', $testFile->getExitMessage());
+ $results = new rtTestResults(null, $testStatus);
} else {
$testStatus->setTrue('bork');
$testStatus->setMessage('bork', $testFile->getExitMessage());

0 comments on commit 24d08e7

Please sign in to comment.