summaryrefslogtreecommitdiff
path: root/ext/curl/tests/curl_write_file.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/curl/tests/curl_write_file.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/curl/tests/curl_write_file.phpt')
-rw-r--r--ext/curl/tests/curl_write_file.phpt38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/curl/tests/curl_write_file.phpt b/ext/curl/tests/curl_write_file.phpt
new file mode 100644
index 0000000..95d2b0e
--- /dev/null
+++ b/ext/curl/tests/curl_write_file.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test curl option CURLOPT_FILE
+--CREDITS--
+Mathieu Kooiman <mathieuk@gmail.com>
+Dutch UG, TestFest 2009, Utrecht
+--DESCRIPTION--
+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().
+--SKIPIF--
+<?php if (!extension_loaded("curl")) print "skip"; ?>
+--FILE--
+<?php
+
+$test_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
+$log_file = tempnam(sys_get_temp_dir(), 'php-curl-test');
+
+$fp = fopen($log_file, 'w+');
+fwrite($fp, "test");
+fclose($fp);
+
+$testfile_fp = fopen($test_file, 'w+');
+
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_FILE, $testfile_fp);
+curl_setopt($ch, CURLOPT_URL, 'file://' . $log_file);
+curl_exec($ch);
+curl_close($ch);
+
+fclose($testfile_fp);
+
+echo file_get_contents($test_file);
+
+// cleanup
+unlink($test_file);
+unlink($log_file);
+
+?>
+--EXPECT--
+test