com phpruntests: PostRaw section: src/testcase/sections/configurationsections/rtPostRawSection.php
| From: | David Soria Parra | Date: | Mon, 04 May 2009 15:45:26 +0000 |
| Subject: | com phpruntests: PostRaw section: src/testcase/sections/configurationsections/rtPostRawSection.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66498@lists.php.net to get a copy of this message | ||
Commit: c5b428d51bcf5ed96fdb49adde8f46a4ea550c86
Author: Zoe Slattery <zoe@php.net> Mon, 4 May 2009 15:45:26 +0000
Parents: 2bd149c6844e397127f58a09d173e19755217584
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=c5b428d51bcf5ed96fdb49adde8f46a4ea550c86
Log:
PostRaw section
Changed paths:
A src/testcase/sections/configurationsections/rtPostRawSection.php
Diff:
diff --git a/src/testcase/sections/configurationsections/rtPostRawSection.php
b/src/testcase/sections/configurationsections/rtPostRawSection.php
new file mode 100644
index 0000000..d140273
--- /dev/null
+++ b/src/testcase/sections/configurationsections/rtPostRawSection.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * rtPostSection
+ * Sets environment variables for POST_RAW 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 rtPostRawSection extends rtConfigurationSection
+{
+ private $postVariables = array();
+ private $postFileName;
+
+ protected function init()
+ {
+ $postContents = array();
+ $isContentSet= false;
+
+ foreach($this->sectionContents as $line) {
+ //get the first - and only the first - Content-Type line
+ if (!$isContentSet && preg_match('/^Content-Type:(.*)/i', $line,
$matches)) {
+ $this->postVariables['CONTENT_TYPE'] =
trim(str_replace("\r", '', $matches[1]));
+ $isContentSet = true;
+ } else {
+ $postContents[] = $line;
+ }
+ }
+
+ $postString = implode('\n', $postContents);
+ $this->postVariables['CONTENT_LENGTH'] = strlen($postString);
+ $this->postVariables['REQUEST_METHOD'] = 'POST';
+
+ $this->postFileName = tempnam(sys_get_temp_dir(), 'post');
+
+ file_put_contents($this->postFileName, $postString);
+}
+
+/**
+ * Additional POST environment variables required by the test
+ *
+ * @return array
+ */
+public function getPostVariables()
+{
+ return $this->postVariables;
+}
+
+/**
+ * return the name of teh file containing post data
+ *
+ */
+public function getPostFileName()
+{
+ return $this->postFileName;
+}
+}
+?>
\ No newline at end of file