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