On 03/17/2012 02:35 AM, Michael Wallner wrote:
mike                                     Sat, 17 Mar 2012 09:35:25 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=324319

Log:
add --PUT-- section support based on POST_RAW

Changed paths:
     U   php/php-src/branches/PHP_5_3/run-tests.php
     U   php/php-src/branches/PHP_5_4/run-tests.php
     U   php/php-src/trunk/run-tests.php

Hi Mike,

Can you update (or get updated) http://qa.php.net/phpt_details.php
with this feature?

Thanks,

Chris


Modified: php/php-src/branches/PHP_5_3/run-tests.php
===================================================================
--- php/php-src/branches/PHP_5_3/run-tests.php  2012-03-17 09:19:10 UTC (rev 
324318)
+++ php/php-src/branches/PHP_5_3/run-tests.php  2012-03-17 09:35:25 UTC (rev 
324319)
@@ -1342,8 +1342,8 @@

        $tested = trim($section_text['TEST']);

-       /* For GET/POST tests, check if cgi sapi is available and if it is, use 
it. */
-       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE']) || 
!empty($section_text['EXPECTHEADERS'])) {
+       /* For GET/POST/PUT tests, check if cgi sapi is available and if it is, 
use it. */
+       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['PUT']) || 
!empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
                if (isset($php_cgi)) {
                        $old_php = $php;
                        $php = $php_cgi . ' -C ';
@@ -1718,6 +1718,46 @@
                save_text($tmp_post, $request);
                $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";

+       } elseif (array_key_exists('PUT', $section_text)&&  
!empty($section_text['PUT'])) {
+
+               $post = trim($section_text['PUT']);
+               $raw_lines = explode("\n", $post);
+
+               $request = '';
+               $started = false;
+
+               foreach ($raw_lines as $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'] = 'PUT';
+
+               if (empty($request)) {
+                       if ($JUNIT) {
+                               $JUNIT['test_total']++;
+                               $JUNIT['test_error']++;
+                               $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" 
name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+                               $JUNIT['result_xml'] .= '<error type="BORKED" message="empty 
$request" />'."\n";
+                               $JUNIT['result_xml'] .= '</testcase>'."\n";
+                       }
+                       return 'BORKED';
+               }
+
+               save_text($tmp_post, $request);
+               $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";
+
        } else if (array_key_exists('POST', $section_text)&&  
!empty($section_text['POST'])) {

                $post = trim($section_text['POST']);

Modified: php/php-src/branches/PHP_5_4/run-tests.php
===================================================================
--- php/php-src/branches/PHP_5_4/run-tests.php  2012-03-17 09:19:10 UTC (rev 
324318)
+++ php/php-src/branches/PHP_5_4/run-tests.php  2012-03-17 09:35:25 UTC (rev 
324319)
@@ -1342,8 +1342,8 @@

        $tested = trim($section_text['TEST']);

-       /* For GET/POST tests, check if cgi sapi is available and if it is, use 
it. */
-       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE']) || 
!empty($section_text['EXPECTHEADERS'])) {
+       /* For GET/POST/PUT tests, check if cgi sapi is available and if it is, 
use it. */
+       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['PUT']) || 
!empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
                if (isset($php_cgi)) {
                        $old_php = $php;
                        $php = $php_cgi . ' -C ';
@@ -1718,6 +1718,46 @@
                save_text($tmp_post, $request);
                $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";

+       } elseif (array_key_exists('PUT', $section_text)&&  
!empty($section_text['PUT'])) {
+
+               $post = trim($section_text['PUT']);
+               $raw_lines = explode("\n", $post);
+
+               $request = '';
+               $started = false;
+
+               foreach ($raw_lines as $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'] = 'PUT';
+
+               if (empty($request)) {
+                       if ($JUNIT) {
+                               $JUNIT['test_total']++;
+                               $JUNIT['test_error']++;
+                               $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" 
name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+                               $JUNIT['result_xml'] .= '<error type="BORKED" message="empty 
$request" />'."\n";
+                               $JUNIT['result_xml'] .= '</testcase>'."\n";
+                       }
+                       return 'BORKED';
+               }
+
+               save_text($tmp_post, $request);
+               $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";
+
        } else if (array_key_exists('POST', $section_text)&&  
!empty($section_text['POST'])) {

                $post = trim($section_text['POST']);

Modified: php/php-src/trunk/run-tests.php
===================================================================
--- php/php-src/trunk/run-tests.php     2012-03-17 09:19:10 UTC (rev 324318)
+++ php/php-src/trunk/run-tests.php     2012-03-17 09:35:25 UTC (rev 324319)
@@ -1342,8 +1342,8 @@

        $tested = trim($section_text['TEST']);

-       /* For GET/POST tests, check if cgi sapi is available and if it is, use 
it. */
-       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE']) || 
!empty($section_text['EXPECTHEADERS'])) {
+       /* For GET/POST/PUT tests, check if cgi sapi is available and if it is, 
use it. */
+       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['PUT']) || 
!empty($section_text['COOKIE']) || !empty($section_text['EXPECTHEADERS'])) {
                if (isset($php_cgi)) {
                        $old_php = $php;
                        $php = $php_cgi . ' -C ';
@@ -1718,6 +1718,46 @@
                save_text($tmp_post, $request);
                $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";

+       } elseif (array_key_exists('PUT', $section_text)&&  
!empty($section_text['PUT'])) {
+
+               $post = trim($section_text['PUT']);
+               $raw_lines = explode("\n", $post);
+
+               $request = '';
+               $started = false;
+
+               foreach ($raw_lines as $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'] = 'PUT';
+
+               if (empty($request)) {
+                       if ($JUNIT) {
+                               $JUNIT['test_total']++;
+                               $JUNIT['test_error']++;
+                               $JUNIT['result_xml'] .= '<testcase classname="'.$shortname.'" 
name="'.htmlspecialchars($tested, ENT_QUOTES).'" time="'.$test_execution_time.'">'."\n";
+                               $JUNIT['result_xml'] .= '<error type="BORKED" message="empty 
$request" />'."\n";
+                               $JUNIT['result_xml'] .= '</testcase>'."\n";
+                       }
+                       return 'BORKED';
+               }
+
+               save_text($tmp_post, $request);
+               $cmd = "$php $pass_options $ini_settings -f \"$test_file\" 2>&1<  
\"$tmp_post\"";
+
        } else if (array_key_exists('POST', $section_text)&&  
!empty($section_text['POST'])) {

                $post = trim($section_text['POST']);





--
Email: christopher.jo...@oracle.com
Tel:  +1 650 506 8630
Blog:  http://blogs.oracle.com/opal/

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to