xref: /PHP-5.3/ext/curl/tests/curl_write_file.phpt (revision 8715a7f1)
1--TEST--
2Test curl option CURLOPT_FILE
3--CREDITS--
4Mathieu Kooiman <mathieuk@gmail.com>
5Dutch UG, TestFest 2009, Utrecht
6--DESCRIPTION--
7Writes 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+');
17fwrite($fp, "test");
18fclose($fp);
19
20$testfile_fp = fopen($test_file, 'w+');
21
22$ch = curl_init();
23curl_setopt($ch, CURLOPT_FILE, $testfile_fp);
24curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
25curl_exec($ch);
26curl_close($ch);
27
28fclose($testfile_fp);
29
30echo file_get_contents($test_file);
31
32// cleanup
33unlink($test_file);
34unlink($log_file);
35
36?>
37--EXPECT--
38test
39