cvs: pear-core /PEAR RunTest.php /tests/PEAR_RunTest test_bug10092cookie.phpt test_bug10092post_raw2.phpt
| From: | Greg Beaver | Date: | Sat, 17 Feb 2007 04:26:36 +0000 |
| Subject: | cvs: pear-core /PEAR RunTest.php /tests/PEAR_RunTest test_bug10092cookie.phpt test_bug10092post_raw2.phpt | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-5429@lists.php.net to get a copy of this message | ||
cellog Sat Feb 17 04:26:36 2007 UTC
Added files:
/pear-core/tests/PEAR_RunTest test_bug10092cookie.phpt
test_bug10092post_raw2.phpt
Modified files:
/pear-core/PEAR RunTest.php
Log:
add full support for cookies, uploaded files, php://input, to
complete fix of bug 10092
Now pear run-tests can test stuffing any conceivable input
that would otherwise be impossible to test
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/RunTest.php?r1=1.27&r2=1.28&diff_format=u
Index: pear-core/PEAR/RunTest.php
diff -u pear-core/PEAR/RunTest.php:1.27 pear-core/PEAR/RunTest.php:1.28
--- pear-core/PEAR/RunTest.php:1.27 Sat Feb 17 00:19:10 2007
+++ pear-core/PEAR/RunTest.php Sat Feb 17 04:26:35 2007
@@ -16,7 +16,7 @@
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: RunTest.php,v 1.27 2007/02/17 00:19:10 cellog Exp $
+ * @version CVS: $Id: RunTest.php,v 1.28 2007/02/17 04:26:35 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.3
*/
@@ -211,8 +211,10 @@
$section_text = array(
'TEST' => '(unnamed test)',
'SKIPIF' => '',
- 'GET' => '',
- 'POST' => '',
+ 'GET' => '',
+ 'COOKIE' => '',
+ 'POST_RAW' => '',
+ 'POST' => '',
'ARGS' => '',
'INI' => '',
'CLEAN' => '',
@@ -258,7 +260,8 @@
} else {
$tested = trim($section_text['TEST']) . ' ';
}
- if (!empty($section_text['GET']) || !empty($section_text['POST'])) {
+ if (!empty($section_text['GET']) || !empty($section_text['POST']) ||
+ !empty($section_text['POST_RAW']) ||
!empty($section_text['COOKIE'])) {
if (empty($this->_options['cgi'])) {
if (!isset($this->_options['quiet'])) {
$this->_logger->log(0, "SKIP $tested (reason: --cgi option needed
for this test, type 'pear help run-tests')");
@@ -377,7 +380,31 @@
$env['QUERY_STRING'] = $query_string;
$env['PATH_TRANSLATED'] = $test_file;
$env['SCRIPT_FILENAME'] = $test_file;
- if (array_key_exists('POST', $section_text) &&
!empty($section_text['POST'])) {
+ if (array_key_exists('POST_RAW', $section_text) &&
!empty($section_text['POST_RAW'])) {
+ $post = trim($section_text['POST_RAW']);
+ $raw_lines = explode("\n", $post);
+
+ $request = '';
+ $started = false;
+ foreach ($raw_lines as $i => $line) {
+ if (empty($env['CONTENT_TYPE']) &&
+ preg_match('/^Content-Type:(.*)/i', $line, $res)) {
+ $env['CONTENT_TYPE'] = trim(str_replace("\r", '',
$res[1]));
+ continue;
+ }
+ if ($started) {
+ $request .= "\n";
+ }
+ $started = true;
+ $request .= $line;
+ }
+
+ $env['CONTENT_LENGTH'] = strlen($request);
+ $env['REQUEST_METHOD'] = 'POST';
+
+ $this->save_text($tmp_post, $request);
+ $cmd = "$php$pass_options$ini_settings -f \"$test_file\" 2>&1
< $tmp_post";
+ } elseif (array_key_exists('POST', $section_text) &&
!empty($section_text['POST'])) {
$post = trim($section_text['POST']);
$this->save_text($tmp_post, $post);
@@ -401,6 +428,9 @@
isset($section_text['STDIN']) ? $section_text['STDIN'] : null);
$return_value = $out[0];
$out = $out[1];
+ if (isset($tmp_post) && file_exists($tmp_post)) {
+ unlink($tmp_post);
+ }
if (isset($section_text['RETURNS'])) {
$section_text['RETURNS'] = (int) trim($section_text['RETURNS']);
$returnfail = ($return_value != $section_text['RETURNS']);
http://cvs.php.net/viewvc.cgi/pear-core/tests/PEAR_RunTest/test_bug10092cookie.phpt?view=markup&rev=1.1
Index: pear-core/tests/PEAR_RunTest/test_bug10092cookie.phpt
+++ pear-core/tests/PEAR_RunTest/test_bug10092cookie.phpt
--TEST--
PEAR_RunTest --COOKIE--
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
?>
--COOKIE--
cookie1=val1 ; cookie2=val2%20; cookie3=val 3.; cookie 4= value 4 %3B; cookie1=bogus;
%20cookie1=ignore;+cookie1=ignore;cookie1;cookie 5=%20 value;
cookie%206=�;cookie+7=;$cookie.8;cookie-9=1;;;- & % $cookie 10=10
--FILE--
<?php
var_dump($_COOKIE);
?>
--EXPECT--
array(10) {
["cookie1"]=>
string(6) "val1 "
["cookie2"]=>
string(5) "val2 "
["cookie3"]=>
string(6) "val 3."
["cookie_4"]=>
string(10) " value 4 ;"
["cookie__5"]=>
string(7) " value"
["cookie_6"]=>
string(3) "�"
["cookie_7"]=>
string(0) ""
["$cookie_8"]=>
string(0) ""
["cookie-9"]=>
string(1) "1"
["-_&_%_$cookie_10"]=>
string(2) "10"
}
http://cvs.php.net/viewvc.cgi/pear-core/tests/PEAR_RunTest/test_bug10092post_raw2.phpt?view=markup&rev=1.1
Index: pear-core/tests/PEAR_RunTest/test_bug10092post_raw2.phpt
+++ pear-core/tests/PEAR_RunTest/test_bug10092post_raw2.phpt
--TEST--
PEAR_RunTest --POST_RAW-- php://input
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
?>
--POST_RAW--
Content-Type: application/x-www-form-urlencoded
userid=joe&password=guessme
--FILE--
<?php
var_dump($_FILES);
var_dump($_POST);
$fp = fopen('php://input', 'r');
$a = fread($fp, 8192);
fclose($fp);
var_dump($a);
?>
--EXPECT--
array(0) {
}
array(2) {
["userid"]=>
string(3) "joe"
["password"]=>
string(7) "guessme"
}
string(27) "userid=joe&password=guessme"