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