com phpruntests: fixes to gzip_post section and a tes t case: src/rtClassMap.php src/testcase/sections/conf igurationsections/rtGzipPostSection.php
tests/testcase/sect ions/configurationsections/rtGzipPostSectionTest.php
| From: | David Soria Parra | Date: | Thu, 30 Apr 2009 08:12:32 +0000 |
| Subject: | com phpruntests: fixes to gzip_post section and a tes t case: src/rtClassMap.php src/testcase/sections/conf igurationsections/rtGzipPostSection.php tests/testcase/sect ions/configurationsections/rtGzipPostSectionTest.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66503@lists.php.net to get a copy of this message | ||
Commit: 00fa073e28855950797419c07422b5774919c920
Author: Zoe Slattery <zoe@php.net> Thu, 30 Apr 2009 08:12:32 +0000
Parents: 4d0e02564f6f7b2951fde29d1b93158ccb70bfb7
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=00fa073e28855950797419c07422b5774919c920
Log:
fixes to gzip_post section and a test case
Changed paths:
M src/rtClassMap.php
M src/testcase/sections/configurationsections/rtGzipPostSection.php
A tests/testcase/sections/configurationsections/rtGzipPostSectionTest.php
Diff:
diff --git a/src/rtClassMap.php b/src/rtClassMap.php
index 714ead3..85ced00 100644
--- a/src/rtClassMap.php
+++ b/src/rtClassMap.php
@@ -58,6 +58,7 @@
'rtArgsSection' =>
'testcase/sections/configurationsections/rtArgsSection.php',
'rtEnvSection' =>
'testcase/sections/configurationsections/rtEnvSection..php',
'rtGetSection' =>
'testcase/sections/configurationsections/rtGetSection.php',
+ 'rtGzipPostSection' =>
'testcase/sections/configurationsections/rtGzipPostSection.php',
'rtIniSection' =>
'testcase/sections/configurationsections/rtIniSection.php',
'rtPostSection' =>
'testcase/sections/configurationsections/rtPostSection.php',
'rtCleanSection' =>
'testcase/sections/executablesections/rtCleanSection.php',
diff --git a/src/testcase/sections/configurationsections/rtGzipPostSection.php
b/src/testcase/sections/configurationsections/rtGzipPostSection.php
index cead7f8..dfabdce 100644
--- a/src/testcase/sections/configurationsections/rtGzipPostSection.php
+++ b/src/testcase/sections/configurationsections/rtGzipPostSection.php
@@ -12,7 +12,7 @@
* @license http://www.php.net/license/3_01.txt
PHP License 3.01
* @link http://qa.php.net/
*/
-class rtPostSection extends rtConfigurationSection
+class rtGzipPostSection extends rtConfigurationSection
{
private $postVariables = array();
private $postFileName;
@@ -21,13 +21,14 @@ class rtPostSection extends rtConfigurationSection
{
$postString = implode('\n', $this->sectionContents);
$gzipPostString = gzencode($postString);
+
$this->postVariables['CONTENT_TYPE'] =
'application/x-www-form-urlencoded';
$this->postVariables['CONTENT_LENGTH'] = strlen($gzipPostString);
$this->postVariables['REQUEST_METHOD'] = 'POST';
$this->postFileName = tempnam(sys_get_temp_dir(), 'post');
- file_put_contents($this->postFileName, $postString);
+ file_put_contents($this->postFileName, $gzipPostString);
}
/**
diff --git a/tests/testcase/sections/configurationsections/rtGzipPostSectionTest.php
b/tests/testcase/sections/configurationsections/rtGzipPostSectionTest.php
new file mode 100644
index 0000000..dbbe87b
--- /dev/null
+++ b/tests/testcase/sections/configurationsections/rtGzipPostSectionTest.php
@@ -0,0 +1,24 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '../../../../../src/rtAutoload.php';
+
+class rtGzipPostSectionTest extends PHPUnit_Framework_TestCase
+{
+ public function testCreateInstance()
+ {
+ $postSection = new rtGzipPostSection('GZIP_POST',
array('hello=World&goodbye=MrChips'));
+
+ $envVars = $postSection->getPostVariables();
+ $this->assertEquals('POST', $envVars['REQUEST_METHOD']);
+
$this->assertEquals('application/x-www-form-urlencoded',$envVars['CONTENT_TYPE']);
+ $this->assertEquals(strlen(gzencode('hello=World&goodbye=MrChips')),
$envVars['CONTENT_LENGTH']);
+
+ $fileName = $postSection->getPostFileName();
+ $string = file_get_contents($fileName);
+
+ $expectedString = gzencode('hello=World&goodbye=MrChips');
+
+ $this->assertEquals($expectedString, $string);
+ }
+}
+?>
\ No newline at end of file