xref: /PHP-5.4/ext/curl/tests/bug55767.phpt (revision 46f74e35)
1--TEST--
2Test curl_opt() function with POST params from array with a numeric key
3--SKIPIF--
4<?php
5if (!extension_loaded("curl")) exit("skip curl extension not loaded");
6if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER'))  exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
7?>
8--FILE--
9<?php
10/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
11 * Description: Set an option for a cURL transfer
12 * Source code: ext/curl/interface.c
13 * Alias to functions:
14 */
15
16  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
17
18  // start testing
19  echo '*** Testing curl sending through GET an POST ***' . "\n";
20
21  $url = "{$host}/get.php?test=getpost&get_param=Hello%20World";
22  $ch = curl_init();
23
24  ob_start(); // start output buffering
25  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
26  curl_setopt($ch, CURLOPT_POST, 1);
27  curl_setopt($ch, CURLOPT_POSTFIELDS, array('Hello'=>'World','Foo'=>'Bar',100=>'John Doe'));
28  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
29
30  $curl_content = curl_exec($ch);
31  curl_close($ch);
32
33  var_dump( $curl_content );
34?>
35===DONE===
36--EXPECTF--
37*** Testing curl sending through GET an POST ***
38string(203) "array(2) {
39  ["test"]=>
40  string(7) "getpost"
41  ["get_param"]=>
42  string(11) "Hello World"
43}
44array(3) {
45  ["Hello"]=>
46  string(5) "World"
47  ["Foo"]=>
48  string(3) "Bar"
49  [100]=>
50  string(8) "John Doe"
51}
52"
53===DONE===
54