com phpruntests: Start of POST implementation: src/rtClassMap.php src/testcase/rtTestConfiguration.php
src/testcase/sections/configurationsections/rtGetSection.php src/testcase/sections/configurationsections/rtPostSection.php
tests/testcase/sections/configurationsections/rtPostSectionTest.php
| From: | David Soria Parra | Date: | Mon, 27 Apr 2009 21:06:34 +0000 |
| Subject: | com phpruntests: Start of POST implementation: src/rtClassMap.php src/testcase/rtTestConfiguration.php src/testcase/sections/configurationsections/rtGetSection.php src/testcase/sections/configurationsections/rtPostSection.php tests/testcase/sections/configurationsections/rtPostSectionTest.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66509@lists.php.net to get a copy of this message | ||
Commit: 01aedf6584b1bdc3443d53ade671191c765edefa
Author: Zoe Slattery <zoe@php.net> Mon, 27 Apr 2009 21:06:34 +0000
Parents: 04c0e98b0f3ad633cd198c52623070c03d0382d3
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=01aedf6584b1bdc3443d53ade671191c765edefa
Log:
Start of POST implementation
Changed paths:
M src/rtClassMap.php
M src/testcase/rtTestConfiguration.php
M src/testcase/sections/configurationsections/rtGetSection.php
A src/testcase/sections/configurationsections/rtPostSection.php
A tests/testcase/sections/configurationsections/rtPostSectionTest.php
Diff:
diff --git a/src/rtClassMap.php b/src/rtClassMap.php
index 3762f0d...714ead3 100644
--- a/src/rtClassMap.php
+++ b/src/rtClassMap.php
@@ -59,6 +59,7 @@
'rtEnvSection' =>
'testcase/sections/configurationsections/rtEnvSection.php',
'rtGetSection' =>
'testcase/sections/configurationsections/rtGetSection.php',
'rtIniSection' =>
'testcase/sections/configurationsections/rtIniSection.php',
+ 'rtPostSection' =>
'testcase/sections/configurationsections/rtPostSection.php',
'rtCleanSection' =>
'testcase/sections/executablesections/rtCleanSection.php',
'rtFileSection' =>
'testcase/sections/executablesections/rtFileSection.php',
'rtSkipIfSection' =>
'testcase/sections/executablesections/rtSkipIfSection.php',
diff --git a/src/testcase/rtTestConfiguration.php b/src/testcase/rtTestConfiguration.php
index a8e322f..8e19590 100644
--- a/src/testcase/rtTestConfiguration.php
+++ b/src/testcase/rtTestConfiguration.php
@@ -21,6 +21,7 @@ class rtTestConfiguration
private $phpCommandLineArguments;
private $testCommandLineArguments;
private $phpExecutable;
+ private $inputFileString;
private $isCgiTest = false;
private $cgiSections = array(
'GET',
@@ -45,7 +46,8 @@ class rtTestConfiguration
$this->setPhpCommandLineArguments($runConfiguration, $sections);
$this->setTestCommandLineArguments($sections);
$this->setPhpExecutable($runConfiguration, $sectionHeadings);
-
+ $this->setInputFileString($runConfiguration, $sections, $sectionHeadings);
+
if($this->isCgiTest) {
$this->environmentVariables['SCRIPT_FILENAME'] =
$fileSection->getFileName();
$this->environmentVariables['PATH_TRANSLATED'] =
$fileSection->getFileName();
@@ -57,6 +59,7 @@ class rtTestConfiguration
private function setEnvironmentVariables(rtRuntestsConfiguration $runConfiguration, $sections,
$fileSection)
{
$this->environmentVariables = $runConfiguration->getEnvironmentVariables();
+
if (array_key_exists('ENV', $sections)) {
$this->environmentVariables = array_merge($this->environmentVariables,
$sections['ENV']->getTestEnvironmentVariables());
}
@@ -94,6 +97,14 @@ class rtTestConfiguration
}
}
+ private function setInputFileString($runConfiguration, $sections, $sectionHeadings)
+ {
+ $this->inputFileString = '';
+ if(in_array('POST', $sectionHeadings)) {
+ $this->inputFileString = '<
'..$sections['POST']->getPostFileName();
+ }
+ }
+
private function queryCgiTest($sectionHeadings)
{
$tempArray = array_diff($this->cgiSections, $sectionHeadings);
diff --git a/src/testcase/sections/configurationsections/rtGetSection.php
b/src/testcase/sections/configurationsections/rtGetSection.php
index 69629f7..420ac5a 100644
--- a/src/testcase/sections/configurationsections/rtGetSection.php
+++ b/src/testcase/sections/configurationsections/rtGetSection.php
@@ -1,17 +1,6 @@
<?php
/**
* rtGetSection
- *
- * @category Testing
- * @package RUNTESTS
- * @author Zoe Slattery <zoe@php.net>
- * @author Stefan Priebsch <spriebsch@php.net>
- * @copyright 2009 The PHP Group
- * @license http://www.php.net/license/3_01.txt
PHP License 3.01
- * @link http://qa.php.net/
- */
-
-/**
* Sets environment variables for GET section
*
*
diff --git a/src/testcase/sections/configurationsections/rtPostSection.php
b/src/testcase/sections/configurationsections/rtPostSection.php
new file mode 100644
index 0000000...8d8a443
--- /dev/null
+++ b/src/testcase/sections/configurationsections/rtPostSection.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * rtPostSection
+ * Sets environment variables for GET section
+ *
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <zoe@php.net>
+ * @author Stefan Priebsch <spriebsch@php.net>
+ * @copyright 2009 The PHP Group
+ * @license http://www.php.net/license/3_01.txt
PHP License 3.01
+ * @link http://qa.php.net/
+ */
+class rtPostSection extends rtConfigurationSection
+{
+ private $postVariables = array();
+ private $postFileName;
+
+ protected function init()
+ {
+ $this->postVariables['CONTENT_TYPE'] =
'application/x-www-form-urlencoded';
+ $this->postVariables['REQUEST_METHOD'] = 'POST';
+
+ $postString = implode('\n', $this->sectionContents);
+ $this->postFileName = tempnam(sys_get_temp_dir(), 'post');
+ file_put_contents($this->postFileName, $postString);
+ }
+
+ /**
+ * Additional GET environment variables required by the test
+ *
+ * @return array
+ */
+ public function getPostVariables()
+ {
+ return $this->postVariables;
+ }
+
+ public function getPostFileName()
+ {
+ return $this->postFileName;
+ }
+}
+?>
\ No newline at end of file
diff --git a/tests/testcase/sections/configurationsections/rtPostSectionTest.php
b/tests/testcase/sections/configurationsections/rtPostSectionTest.php
new file mode 100644
index 0000000..2096f41
--- /dev/null
+++ b/tests/testcase/sections/configurationsections/rtPostSectionTest.php
@@ -0,0 +1,20 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '../../../../../src/rtAutoload.php';
+
+class rtPostSectionTest extends PHPUnit_Framework_TestCase
+{
+ public function testCreateInstance()
+ {
+ $postSection = new rtPostSection('POST',
array('hello=World&goodbye=MrChips'));
+
+ $envVars = $postSection->getPostVariables();
+ $this->assertEquals('POST', $envVars['REQUEST_METHOD']);
+
+ $fileName = $postSection->getPostFileName();
+ $string = file_get_contents($fileName);
+
+ $this->assertEquals('hello=World&goodbye=MrChips', $string);
+ }
+}
+?>
\ No newline at end of file