- Fix tests to be more comptatible AND to test what they are supposed to test

This commit is contained in:
Jani Taskinen 2009-07-25 22:20:18 +00:00
parent badd102c83
commit bc8155d737
4 changed files with 23 additions and 21 deletions

View 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) {

View 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===
string(9) "cURL phpt"
===DONE===

View 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);

View 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');
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));
fclose($handle);
unset($handle);
var_dump( file_get_contents($temp_file) );
@unlink($temp_file);
curl_close($ch);
@unlink($temp_file);
?>
--EXPECTF--
*** Testing curl_setopt with CURLOPT_STDERR
string(%d) "%s%w"
string(%d) "%S"
string(%d) "%S"