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

1.1       misho       1: --TEST--
                      2: Test curl option CURLOPT_FILE 
                      3: --CREDITS--
                      4: Mathieu Kooiman <mathieuk@gmail.com>
                      5: Dutch UG, TestFest 2009, Utrecht
                      6: --DESCRIPTION--
                      7: Writes the value 'test' to a temporary file. Use curl to access this file and store the output in another temporary file. Tests the PHP_CURL_FILE case in curl_write().
                      8: --SKIPIF--
                      9: <?php if (!extension_loaded("curl")) print "skip"; ?>
                     10: --FILE--
                     11: <?php
                     12: 
                     13: $test_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
                     14: $log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
                     15: 
                     16: $fp = fopen($log_file, 'w+');
                     17: fwrite($fp, "test");
                     18: fclose($fp);
                     19: 
                     20: $testfile_fp = fopen($test_file, 'w+');
                     21: 
                     22: $ch = curl_init();
                     23: curl_setopt($ch, CURLOPT_FILE, $testfile_fp);
                     24: curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
                     25: curl_exec($ch);
                     26: curl_close($ch);
                     27: 
                     28: fclose($testfile_fp);
                     29: 
                     30: echo file_get_contents($test_file);
                     31: 
                     32: // cleanup
                     33: unlink($test_file);
                     34: unlink($log_file);
                     35: 
                     36: ?>
                     37: --EXPECT--
                     38: test

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