PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/curl/tests/bug55767.phpt ('Test curl_opt() function with POST params from array with a numeric key')

Script

1: <?php
2:
/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
3:  * Description: Set an option for a cURL transfer
4:  * Source code: ext/curl/interface.c
5:  * Alias to functions:
6:  */
7:
8:   
include 'server.inc';
9:   
$host curl_cli_server_start();
10:
11:   
// start testing
12:   
echo '*** Testing curl sending through GET an POST ***' "\n";
13:
14:   
$url "{$host}/get.inc?test=getpost&get_param=Hello%20World";
15:   
$ch curl_init();
16:
17:   
ob_start(); // start output buffering
18:   
curl_setopt($chCURLOPT_RETURNTRANSFER1);
19:   
curl_setopt($chCURLOPT_POST1);
20:   
curl_setopt($chCURLOPT_POSTFIELDS, array('Hello'=>'World','Foo'=>'Bar',100=>'John Doe'));
21:   
curl_setopt($chCURLOPT_URL$url); //set the url we want to use
22:
23:   
$curl_content curl_exec($ch);
24:   
curl_close($ch);
25:
26:   
var_dump$curl_content );
27:
?>
28:
===DONE===
29:

Expected

*** Testing curl sending through GET an POST ***
string(203) "array(2) {
  ["test"]=>
  string(7) "getpost"
  ["get_param"]=>
  string(11) "Hello World"
}
array(3) {
  ["Hello"]=>
  string(5) "World"
  ["Foo"]=>
  string(3) "Bar"
  [100]=>
  string(8) "John Doe"
}
"
===DONE===

Output

*** Testing curl sending through GET an POST ***
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
===DONE===

Diff

002+ string(973) "<?php
003+   $test = isset($_GET['test']) ? $_GET['test'] : null;
004+   switch($test) {
005+     case 'post':
006+       var_dump($_POST);
007+       break;
008+     case 'getpost':
009+       var_dump($_GET);
010+       var_dump($_POST);
011+       break;
012+     case 'referer':
013+       echo $_SERVER['HTTP_REFERER'];
014+       break;
015+     case 'useragent':
016+       echo $_SERVER['HTTP_USER_AGENT'];
017+       break;
002- string(203) "array(2) {
003-   ["test"]=>
004-   string(7) "getpost"
005-   ["get_param"]=>
006-   string(11) "Hello World"
007- }
008- array(3) {
009-   ["Hello"]=>
010-   string(5) "World"
011-   ["Foo"]=>
012-   string(3) "Bar"
013-   [100]=>
014-   string(8) "John Doe"
015- }
016- "
017- ===DONE===
018+     case 'httpversion':
019+       echo $_SERVER['SERVER_PROTOCOL'];
020+       break;
021+     case 'cookie':
022+       echo $_COOKIE['foo'];
023+       break;
024+     case 'encoding':
025+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
026+       break;
027+     case 'contenttype':
028+       header('Content-Type: text/plain;charset=utf-8');
029+       break;
030+     case 'file':
031+       if (isset($_FILES['file'])) {
032+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
033+       }
034+       break;
035+     case 'method':
036+       echo $_SERVER['REQUEST_METHOD'];
037+       break;
038+     default:
039+       echo "Hello World!\n";
040+       echo "Hello World!";
041+       break;
042+   }
043+ ?>
044+ "
045+ ===DONE===

 

Generated at Tue, 19 Mar 2019 00:18:08 +0000 (4 days ago)

Copyright © 2005-2019 The PHP Group
All rights reserved.