com phpruntests: deflate post section: src/rtClassMap.php src/testcase/sections/configurationsections/rtDeflatePostSection.php
tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
| From: | David Soria Parra | Date: | Thu, 30 Apr 2009 20:07:43 +0000 |
| Subject: | com phpruntests: deflate post section: src/rtClassMap.php src/testcase/sections/configurationsections/rtDeflatePostSection.php tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66501@lists.php.net to get a copy of this message | ||
Commit: 7e7f936a45cc98d4ae25c1ac141549a2070550ff
Author: Zoe Slattery <zoe@php.net> Thu, 30 Apr 2009 20:07:43 +0000
Parents: 9f26e0ca3e8fffed931300153e2b195584c06902
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=7e7f936a45cc98d4ae25c1ac141549a2070550ff
Log:
deflate post section
Changed paths:
M src/rtClassMap.php
A src/testcase/sections/configurationsections/rtDeflatePostSection.php
A tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
Diff:
diff --git a/src/rtClassMap.php b/src/rtClassMap.php
index 85ced00..f867978 100644
--- a/src/rtClassMap.php
+++ b/src/rtClassMap.php
@@ -56,6 +56,7 @@
'rtTestPreCondition' =>
'testcase/rtTestPreCondition.php',
'rtTestResults' =>
'testcase/rtTestResults.php',
'rtArgsSection' =>
'testcase/sections/configurationsections/rtArgsSection.php',
+ 'rtDeflatePostSection' =>
'testcase/sections/configurationsections/rtDeflatePostSection.php',
'rtEnvSection' =>
'testcase/sections/configurationsections/rtEnvSection.php',
'rtGetSection' =>
'testcase/sections/configurationsections/rtGetSection.php',
'rtGzipPostSection' =>
'testcase/sections/configurationsections/rtGzipPostSection.php',
diff --git a/src/testcase/sections/configurationsections/rtDeflatePostSection.php
b/src/testcase/sections/configurationsections/rtDeflatePostSection.php
new file mode 100644
index 0000000..6e43015
--- /dev/null
+++ b/src/testcase/sections/configurationsections/rtDeflatePostSection.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * rtPostSection
+ * Sets environment variables for DEFLATE_POST 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 rtDeflatePostSection extends rtConfigurationSection
+{
+ private $postVariables = array();
+ private $postFileName;
+
+ protected function init()
+ {
+ $postString = implode('\n', $this->sectionContents);
+ $compressedPostString = gzcompress($postString);
+
+ $this->postVariables['CONTENT_TYPE'] =
'application/x-www-form-urlencoded';
+ $this->postVariables['CONTENT_LENGTH'] = strlen($compressedPostString);
+ $this->postVariables['REQUEST_METHOD'] = 'POST';
+
+ $this->postFileName = tempnam(sys_get_temp_dir(), 'post');
+
+ file_put_contents($this->postFileName, $compressedPostString);
+ }
+
+ /**
+ * Additional POST 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/rtDeflatePostSectionTest.php
b/tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
new file mode 100644
index 0000000..1677581
--- /dev/null
+++ b/tests/testcase/sections/configurationsections/rtDeflatePostSectionTest.php
@@ -0,0 +1,24 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . '../../.../../../src/rtAutoload.php';
+
+class rtDeflatePostSectionTest extends PHPUnit_Framework_TestCase
+{
+ public function testCreateInstance()
+ {
+ $postSection = new rtDeflatePostSection('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(gzcompress('hello=World&goodbye=MrChips')),
$envVars['CONTENT_LENGTH']);
+
+ $fileName = $postSection->getPostFileName();
+ $string = file_get_contents($fileName);
+
+ $expectedString = gzcompress('hello=World&goodbye=MrChips');
+
+ $this->assertEquals($expectedString, $string);
+ }
+}
+?>
\ No newline at end of file