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/curl_setopt_array_basic.phpt ('curl_setopt_array() function - tests setting multiple cURL options with curl_setopt_array()')

Script

1: <?php
2:
/*
3:  * Prototype:     bool curl_setopt_array(resource $ch, array $options)
4:  * Description:   Sets multiple options for a cURL session.
5:  * Source:        ext/curl/interface.c
6:  * Documentation: http://wiki.php.net/qa/temp/ext/curl
7:  */
8:
9: // Figure out what handler to use
10:
include 'server.inc';
11:
$host curl_cli_server_start();
12: if (!empty(
$host)) {
13:     
// Use the set Environment variable
14:     
$url "{$host}/get.inc?test=get";
15: } else {
16:     
// Create a temporary file for the test
17:     
$tempname tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
18:     
$url 'file://'$tempname;
19:     
// add the test data to the file
20:     
file_put_contents($tempname"Hello World!\nHello World!");
21: }
22:
23:
// Start the test
24:
echo '== Starting test curl_setopt_array($ch, $options); ==' "\n";
25:
26:
// curl handler
27:
$ch curl_init();
28:
29:
// options for the curl handler
30:
$options = array (
31:     
CURLOPT_URL => $url,
32:     
CURLOPT_RETURNTRANSFER => 1
33:
);
34:
35:
ob_start(); // start output buffering
36:
37:
curl_setopt_array($ch$options);
38:
$returnContent curl_exec($ch);
39:
curl_close($ch);
40:
41:
var_dump($returnContent);
42: isset(
$tempname) and is_file($tempname) and @unlink($tempname);
43:
44:
?>
45:

Expected

== Starting test curl_setopt_array($ch, $options); ==
string(25) "Hello World!
Hello World!"

Output

== Starting test curl_setopt_array($ch, $options); ==
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;
  }
?>
"

Diff

002+ string(973) "<?php
003+   $test = isset($_GET['test']) ? $_GET['test'] : null;
002- string(25) "Hello World!
003- Hello World!"
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;
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+ "

 

Generated at Mon, 06 May 2019 17:58:35 +0000 (50 days ago)

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