Annotation of embedaddon/php/ext/curl/tests/bug48207.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test curl_setopt() CURLOPT_FILE readonly file handle
        !             3: --CREDITS--
        !             4: Mark van der Velden
        !             5: #testfest Utrecht 2009
        !             6: --SKIPIF--
        !             7: <?php if (!extension_loaded("curl")) print "skip"; ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /*
        !            11:  * Description       : Adds a file which stores the received data from curl_exec();
        !            12:  * Source code       : ext/curl/multi.c
        !            13:  * Test documentation: http://wiki.php.net/qa/temp/ext/curl
        !            14:  */
        !            15: 
        !            16: // Figure out what handler to use
        !            17: $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
        !            18: if(!empty($host)) {
        !            19: 
        !            20:     // Use the set Environment variable
        !            21:     $url = "$host/get.php?test=1";
        !            22: 
        !            23: } else {
        !            24: 
        !            25:     // Create a temporary file for the test
        !            26:     $tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
        !            27:     $url = 'file://'. $tempname;
        !            28: 
        !            29:     // add the test data to the file
        !            30:     file_put_contents($tempname, "Hello World!\nHello World!");
        !            31: }
        !            32: 
        !            33: 
        !            34: $tempfile      = tempnam(sys_get_temp_dir(), 'CURL_FILE_HANDLE');
        !            35: 
        !            36: $ch = curl_init($url);
        !            37: $fp = fopen($tempfile, "r"); // Opening 'fubar' with the incorrect readonly flag
        !            38: curl_setopt($ch, CURLOPT_FILE, $fp);
        !            39: curl_exec($ch);
        !            40: curl_close($ch);
        !            41: is_file($tempfile) and @unlink($tempfile);
        !            42: isset($tempname) and is_file($tempname) and @unlink($tempname);
        !            43: ?>
        !            44: --EXPECTF--
        !            45: Warning: curl_setopt(): the provided file handle is not writable in %s on line %d
        !            46: Hello World!
        !            47: Hello World!

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