]> granicus.if.org Git - php/commitdiff
- Fix tests to be more comptatible AND to test what they are supposed to test
authorJani Taskinen <jani@php.net>
Sat, 25 Jul 2009 22:20:18 +0000 (22:20 +0000)
committerJani Taskinen <jani@php.net>
Sat, 25 Jul 2009 22:20:18 +0000 (22:20 +0000)
ext/curl/tests/curl_CURLOPT_READDATA.phpt
ext/curl/tests/curl_copy_handle_basic_006.phpt
ext/curl/tests/curl_copy_handle_basic_007.phpt
ext/curl/tests/curl_setopt_basic002.phpt

index e32c59230a7adbb4c2a99f6c331223fa7a92bc44..00f3ea95ab4734fb4bce0bdf0f2a5544266e2b66 100644 (file)
@@ -33,7 +33,7 @@ if (false === $response = curl_exec($ch)) {
 curl_close($ch);
 
 // Clean the temporary file
-unset($tempname);
+@unlink($tempname);
 
 --EXPECT--
 array(2) {
index 3026da81e0e28524b95498add8602493ee0f9ca9..d2374c72135265687c1ab81e8da6b6a9c8473c81 100644 (file)
@@ -21,15 +21,17 @@ Rick Buitenman <rick@meritos.nl>
   curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
   
   $copy = curl_copy_handle($ch);
-  curl_close($ch);
-  $curl_content = curl_exec($copy);
+
+  var_dump( curl_exec($ch) );
+  var_dump( curl_exec($copy) );
+
+  curl_close($ch); // can not close original handle before curl_exec($copy) since it causes char * inputs to be invalid (see also: http://curl.haxx.se/libcurl/c/curl_easy_duphandle.html)
   curl_close($copy);
 
-  var_dump( $curl_content );
 ?>
 ===DONE===
 --EXPECTF--
 *** Testing curl copy handle with User Agent ***
 string(9) "cURL phpt"
-===DONE===  
\ No newline at end of file
+string(9) "cURL phpt"
+===DONE===  
index 5be9048af6d664fa26f200a5da2fbe38d27382f2..a51d9f6dfaf52cb5757f97df3357b973de26558f 100644 (file)
@@ -15,6 +15,7 @@ Test curl_copy_handle() with simple POST
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, array("Hello" => "World", "Foo" => "Bar", "Person" => "John Doe"));
+  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // Disable Expect: header (lighttpd does not support it :)
   curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
   
   $copy = curl_copy_handle($ch);
index d60c5d04d7bb62459b945c487bb7c0445dff254c..051703fb0874b550216dccb82a8556e0a0a282db 100644 (file)
@@ -13,7 +13,8 @@ $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
 // start testing
 echo "*** Testing curl_setopt with CURLOPT_STDERR\n";
 
-$temp_file = tempnam(sys_get_temp_dir(), '');
+$temp_file = tempnam(sys_get_temp_dir(), 'CURL_STDERR');
+
 $handle = fopen($temp_file, 'w');
 
 $url = "{$host}/";
@@ -21,31 +22,29 @@ $ch = curl_init();
 
 curl_setopt($ch, CURLOPT_VERBOSE, 1);
 curl_setopt($ch, CURLOPT_STDERR, $handle);
-
 $curl_content = curl_exec($ch);
-fclose($handle);
 
-var_dump( curl_error($ch) );
-var_dump( file_get_contents($temp_file));
-
-@unlink ($temp_file);
-$handle = fopen($temp_file, 'w');
+fclose($handle);
+unset($handle);
+var_dump( file_get_contents($temp_file) );
+@unlink($temp_file);
 
 ob_start(); // start output buffering
-curl_setopt($ch, CURLOPT_VERBOSE, 1);
-curl_setopt($ch, CURLOPT_STDERR, $handle);
+$handle = fopen($temp_file, 'w');
 curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
-
+curl_setopt($ch, CURLOPT_STDERR, $handle);
 $data = curl_exec($ch);
-fclose($handle);
 ob_end_clean();
-var_dump(file_get_contents($temp_file));
 
-curl_close($ch);
+fclose($handle);
+unset($handle);
+var_dump( file_get_contents($temp_file) );
 @unlink($temp_file);
+
+curl_close($ch);
+
 ?>
 --EXPECTF--
 *** Testing curl_setopt with CURLOPT_STDERR
-string(%d) "%s%w"
 string(%d) "%S"
 string(%d) "%S"