Annotation of embedaddon/php/ext/curl/tests/curl_setopt_array_basic.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: curl_setopt_array() function - tests setting multiple cURL options with curl_setopt_array()
                      3: --CREDITS--
                      4: Mattijs Hoitink mattijshoitink@gmail.com
                      5: #Testfest Utrecht 2009
                      6: --SKIPIF--
                      7: <?php if (!extension_loaded("curl")) print "skip"; ?>
                      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
                     18: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
                     19: if (!empty($host)) {
                     20:     // Use the set Environment variable
                     21:     $url = "{$host}/get.php?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
                     31: echo '== 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: 
                     42: ob_start(); // start output buffering
                     43: 
                     44: curl_setopt_array($ch, $options);
                     45: $returnContent = curl_exec($ch);
                     46: curl_close($ch);
                     47: 
                     48: var_dump($returnContent);
                     49: isset($tempname) and is_file($tempname) and @unlink($tempname);
                     50: 
                     51: ?>
                     52: --EXPECT--
                     53: == Starting test curl_setopt_array($ch, $options); ==
                     54: string(25) "Hello World!
                     55: Hello World!"
                     56: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>