diff options
author | Stanislav Malyshev <stas@php.net> | 2014-05-11 22:44:30 -0700 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2014-05-11 23:03:21 -0700 |
commit | 89798f57d4a6552b08efeee24bf54079b072c771 (patch) | |
tree | 1c2fceef5857096e214cf351e0576dc883196fe1 | |
parent | 997be125eb0228c5b1b6dd278f617791e71192c6 (diff) | |
parent | c507c9f01b10d7d991e38af55d22fad122dfbdf8 (diff) | |
download | php-git-89798f57d4a6552b08efeee24bf54079b072c771.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
improve CURL tests to allow testing without separate server
45 files changed, 231 insertions, 187 deletions
diff --git a/ext/curl/tests/bug27023.phpt b/ext/curl/tests/bug27023.phpt index 62effec990..fce69f5708 100644 --- a/ext/curl/tests/bug27023.phpt +++ b/ext/curl/tests/bug27023.phpt @@ -4,18 +4,15 @@ Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) error_reporting = E_ALL & ~E_DEPRECATED --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $ch = curl_init(); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/bug27023_2.phpt b/ext/curl/tests/bug27023_2.phpt new file mode 100644 index 0000000000..c878ebac31 --- /dev/null +++ b/ext/curl/tests/bug27023_2.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files) +--INI-- +error_reporting = E_ALL & ~E_DEPRECATED +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php + +include 'server.inc'; +$host = curl_cli_server_start(); +$ch = curl_init(); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1); +curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt'); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', null, "foo.txt"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + +$file = curl_file_create(__DIR__ . '/curl_testdata1.txt', "text/plain", "foo.txt"); +$params = array('file' => $file); +curl_setopt($ch, CURLOPT_POSTFIELDS, $params); +var_dump(curl_exec($ch)); + + +curl_close($ch); +?> +--EXPECTF-- +string(%d) "curl_testdata1.txt|application/octet-stream" +string(%d) "curl_testdata1.txt|text/plain" +string(%d) "foo.txt|application/octet-stream" +string(%d) "foo.txt|text/plain" diff --git a/ext/curl/tests/bug45161.phpt b/ext/curl/tests/bug45161.phpt index 9fdc7a7e22..bfcd244004 100644 --- a/ext/curl/tests/bug45161.phpt +++ b/ext/curl/tests/bug45161.phpt @@ -8,9 +8,6 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { if (!extension_loaded("curl")) { exit("skip curl extension not loaded"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} $curl_version = curl_version(); if ($curl_version['version_number'] < 0x071100) { exit("skip: test works only with curl >= 7.17.0"); diff --git a/ext/curl/tests/bug46711.phpt b/ext/curl/tests/bug46711.phpt index 8eef5562fe..3149c45d7e 100644 --- a/ext/curl/tests/bug46711.phpt +++ b/ext/curl/tests/bug46711.phpt @@ -5,9 +5,6 @@ Bug #46711 (lost memory when foreach is used for values passed to curl_setopt()) if (!extension_loaded("curl")) { exit("skip curl extension not loaded"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} ?> --FILE-- <?php diff --git a/ext/curl/tests/bug48203.phpt b/ext/curl/tests/bug48203.phpt index d8f4d2269f..aae7fc51a4 100644 --- a/ext/curl/tests/bug48203.phpt +++ b/ext/curl/tests/bug48203.phpt @@ -1,24 +1,17 @@ --TEST-- Bug #48203 (Crash when CURLOPT_STDERR is set to regular file) --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - +include 'server.inc'; $fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_STDERR, $fp); -curl_setopt($ch, CURLOPT_URL, getenv('PHP_CURL_HTTP_REMOTE_SERVER')); +curl_setopt($ch, CURLOPT_URL, curl_cli_server_start()); fclose($fp); // <-- premature close of $fp caused a crash! diff --git a/ext/curl/tests/bug48203_multi.phpt b/ext/curl/tests/bug48203_multi.phpt index 501b77843e..e28c990e93 100644 --- a/ext/curl/tests/bug48203_multi.phpt +++ b/ext/curl/tests/bug48203_multi.phpt @@ -2,16 +2,11 @@ Variation of bug #48203 with curl_multi_exec (Crash when file pointers passed to curl are closed before calling curl_multi_exec) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php - +include 'server.inc'; function checkForClosedFilePointer($curl_option, $description) { $fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w'); @@ -21,7 +16,7 @@ function checkForClosedFilePointer($curl_option, $description) { $options = array( CURLOPT_RETURNTRANSFER => 1, $curl_option => $fp, - CURLOPT_URL => getenv("PHP_CURL_HTTP_REMOTE_SERVER") + CURLOPT_URL => curl_cli_server_start() ); // we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly diff --git a/ext/curl/tests/bug48207.phpt b/ext/curl/tests/bug48207.phpt index 6ac16f5ea8..a3cd81544b 100644 --- a/ext/curl/tests/bug48207.phpt +++ b/ext/curl/tests/bug48207.phpt @@ -4,7 +4,7 @@ Test curl_setopt() CURLOPT_FILE readonly file handle Mark van der Velden #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* @@ -14,7 +14,8 @@ Mark van der Velden */ // Figure out what handler to use -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); if(!empty($host)) { // Use the set Environment variable diff --git a/ext/curl/tests/bug54798.phpt b/ext/curl/tests/bug54798.phpt index afd98cb87e..4a9b999940 100644 --- a/ext/curl/tests/bug54798.phpt +++ b/ext/curl/tests/bug54798.phpt @@ -2,12 +2,7 @@ Bug #54798 (Segfault when CURLOPT_STDERR file pointer is closed before calling curl_exec) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} +include 'skipif.inc'; ?> --FILE-- <?php @@ -47,7 +42,8 @@ $options_to_check = array( "CURLOPT_INFILE" ); -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); foreach($options_to_check as $option) { checkForClosedFilePointer($host, constant($option), $option); } diff --git a/ext/curl/tests/bug54995.phpt b/ext/curl/tests/bug54995.phpt index 0f3f50f344..4af59948be 100644 --- a/ext/curl/tests/bug54995.phpt +++ b/ext/curl/tests/bug54995.phpt @@ -2,20 +2,16 @@ Bug #54995 (Missing CURLINFO_RESPONSE_CODE support) --SKIPIF-- <?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} +include 'skipif.inc'; + if ($curl_version['version_number'] > 0x070a08) { exit("skip: tests works a versions of curl >= 7.10.8"); } -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} ?> --FILE-- <?php - -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/bug55767.phpt b/ext/curl/tests/bug55767.phpt index 321f67ba60..161ced0bf1 100644 --- a/ext/curl/tests/bug55767.phpt +++ b/ext/curl/tests/bug55767.phpt @@ -2,8 +2,7 @@ Test curl_opt() function with POST params from array with a numeric key --SKIPIF-- <?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); +include 'skipinf.inc'; ?> --FILE-- <?php @@ -13,7 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl sending through GET an POST ***' . "\n"; diff --git a/ext/curl/tests/bug66109.phpt b/ext/curl/tests/bug66109.phpt index aacfba438a..5a18e97294 100644 --- a/ext/curl/tests/bug66109.phpt +++ b/ext/curl/tests/bug66109.phpt @@ -1,18 +1,11 @@ --TEST-- Bug #66109 (Option CURLOPT_CUSTOMREQUEST can't be reset to default.) --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=method"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/curl_CURLOPT_READDATA.phpt b/ext/curl/tests/curl_CURLOPT_READDATA.phpt index ea63d445ac..25bd0e9b49 100644 --- a/ext/curl/tests/curl_CURLOPT_READDATA.phpt +++ b/ext/curl/tests/curl_CURLOPT_READDATA.phpt @@ -4,12 +4,14 @@ Test CURLOPT_READDATA without a callback function Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php +include 'server.inc'; +$host = curl_cli_server_start(); // The URL to POST to -$url = getenv('PHP_CURL_HTTP_REMOTE_SERVER') . '/get.php?test=post'; +$url = $host . '/get.php?test=post'; // Create a temporary file to read the data from $tempname = tempnam(sys_get_temp_dir(), 'CURL_DATA'); diff --git a/ext/curl/tests/curl_basic_001.phpt b/ext/curl/tests/curl_basic_001.phpt index fa362b33ce..4921b69bdd 100644 --- a/ext/curl/tests/curl_basic_001.phpt +++ b/ext/curl/tests/curl_basic_001.phpt @@ -4,10 +4,7 @@ Test curl_exec() function with basic functionality Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_exec(resource ch) @@ -15,8 +12,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Source code: ext/curl/interface.c * Alias to functions: */ - - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_002.phpt b/ext/curl/tests/curl_basic_002.phpt index e46f323b5a..69aef4b825 100644 --- a/ext/curl/tests/curl_basic_002.phpt +++ b/ext/curl/tests/curl_basic_002.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_RETURNTRANSFER parameter set to 1 Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_003.phpt b/ext/curl/tests/curl_basic_003.phpt index eb2aecdd8f..9c5967db8f 100644 --- a/ext/curl/tests/curl_basic_003.phpt +++ b/ext/curl/tests/curl_basic_003.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with POST parameters Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl sending through GET an POST ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_004.phpt b/ext/curl/tests/curl_basic_004.phpt index ea2eeca87c..08dc7a1005 100644 --- a/ext/curl/tests/curl_basic_004.phpt +++ b/ext/curl/tests/curl_basic_004.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with setting referer Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl setting referer ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_005.phpt b/ext/curl/tests/curl_basic_005.phpt index 9285c108e2..200db765dc 100644 --- a/ext/curl/tests/curl_basic_005.phpt +++ b/ext/curl/tests/curl_basic_005.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with user agent Sebastian Deutsch <sebastian.deutsch@9elements.com> TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with user agent ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_006.phpt b/ext/curl/tests/curl_basic_006.phpt index 5f1a4f4839..66ca036a96 100644 --- a/ext/curl/tests/curl_basic_006.phpt +++ b/ext/curl/tests/curl_basic_006.phpt @@ -4,10 +4,7 @@ Test curl_opt() function with CURLOPT_WRITEFUNCTION parameter set to a closure ? TestFest 2009 - AFUP - Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -16,7 +13,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_R * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl_setopt($ch, CURLOPT_WRITEFUNCTION, <closure>); ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_011.phpt b/ext/curl/tests/curl_basic_011.phpt index 10c90b123a..4e33082409 100644 --- a/ext/curl/tests/curl_basic_011.phpt +++ b/ext/curl/tests/curl_basic_011.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with COOKIE --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with cookie ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_012.phpt b/ext/curl/tests/curl_basic_012.phpt index e4706fad46..f136880dff 100644 --- a/ext/curl/tests/curl_basic_012.phpt +++ b/ext/curl/tests/curl_basic_012.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_0 --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with HTTP/1.0 ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_013.phpt b/ext/curl/tests/curl_basic_013.phpt index c49d187be3..6d09517e8d 100644 --- a/ext/curl/tests/curl_basic_013.phpt +++ b/ext/curl/tests/curl_basic_013.phpt @@ -3,7 +3,7 @@ Test curl_opt() function with CURLOPT_HTTP_VERSION/CURL_HTTP_VERSION_1_1 --CREDITS-- TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo '*** Testing curl with HTTP/1.1 ***' . "\n"; diff --git a/ext/curl/tests/curl_basic_017.phpt b/ext/curl/tests/curl_basic_017.phpt index 09247b2c69..dc0bee926b 100644 --- a/ext/curl/tests/curl_basic_017.phpt +++ b/ext/curl/tests/curl_basic_017.phpt @@ -3,7 +3,7 @@ Test curl_multi_exec() function with basic functionality --CREDITS-- TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_multi_exec(resource ch) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_018.phpt b/ext/curl/tests/curl_basic_018.phpt index 7cffb89f01..359421fc0a 100644 --- a/ext/curl/tests/curl_basic_018.phpt +++ b/ext/curl/tests/curl_basic_018.phpt @@ -3,7 +3,7 @@ Test curl_setopt() with curl_multi function with basic functionality --CREDITS-- TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* Prototype : bool curl_setopt(resource ch, int option, mixed value) @@ -12,7 +12,8 @@ TestFest 2009 - AFUP - Thomas Rabaix <thomas.rabaix@gmail.com> * Alias to functions: */ - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); // start testing echo "*** Testing curl_exec() : basic functionality ***\n"; diff --git a/ext/curl/tests/curl_basic_019.phpt b/ext/curl/tests/curl_basic_019.phpt index ab605a8c7d..2c58500ef7 100644 --- a/ext/curl/tests/curl_basic_019.phpt +++ b/ext/curl/tests/curl_basic_019.phpt @@ -3,22 +3,19 @@ Test curl_getinfo() function with CURLINFO_EFFECTIVE_URL parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); - $url = "{$host}/get.php?test="; + $url = "http://{$host}/get.php?test="; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); $info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); var_dump($url == $info); - curl_close($ch); ?> ===DONE=== diff --git a/ext/curl/tests/curl_basic_020.phpt b/ext/curl/tests/curl_basic_020.phpt index d622053506..1227ad3261 100644 --- a/ext/curl/tests/curl_basic_020.phpt +++ b/ext/curl/tests/curl_basic_020.phpt @@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_HTTP_CODE parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php?test="; $ch = curl_init(); diff --git a/ext/curl/tests/curl_basic_021.phpt b/ext/curl/tests/curl_basic_021.phpt index 3b4798d515..d9f5a90bef 100644 --- a/ext/curl/tests/curl_basic_021.phpt +++ b/ext/curl/tests/curl_basic_021.phpt @@ -3,13 +3,11 @@ Test curl_getinfo() function with CURLINFO_CONTENT_TYPE parameter --CREDITS-- Jean-Marc Fontaine <jmf@durcommefaire.net> --SKIPIF-- -<?php -if (!extension_loaded("curl")) exit("skip curl extension not loaded"); -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php?test=contenttype"; $ch = curl_init(); diff --git a/ext/curl/tests/curl_copy_handle_basic_001.phpt b/ext/curl/tests/curl_copy_handle_basic_001.phpt index f1b4db3ce5..aafa41ee2e 100644 --- a/ext/curl/tests/curl_copy_handle_basic_001.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_001.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() with simple get Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple GET ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_002.phpt b/ext/curl/tests/curl_copy_handle_basic_002.phpt index 9ab33635fb..6e8214ad2b 100644 --- a/ext/curl/tests/curl_copy_handle_basic_002.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_002.phpt @@ -4,10 +4,11 @@ Test curl_copy_handle() with simple POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple POST ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_004.phpt b/ext/curl/tests/curl_copy_handle_basic_004.phpt index 9b794e91b4..c690180a55 100644 --- a/ext/curl/tests/curl_copy_handle_basic_004.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_004.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() after exec() Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Test curl_copy_handle() after exec() ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_005.phpt b/ext/curl/tests/curl_copy_handle_basic_005.phpt index aa9e2fa998..e92603324e 100644 --- a/ext/curl/tests/curl_copy_handle_basic_005.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_005.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() after exec() with POST Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Test curl_copy_handle() after exec() with POST ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_006.phpt b/ext/curl/tests/curl_copy_handle_basic_006.phpt index defc0f232a..0a5c2a25e6 100644 --- a/ext/curl/tests/curl_copy_handle_basic_006.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_006.phpt @@ -4,11 +4,12 @@ Test curl_copy_handle() with User Agent Rick Buitenman <rick@meritos.nl> #testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with User Agent ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_007.phpt b/ext/curl/tests/curl_copy_handle_basic_007.phpt index aa7306c1c9..6334d2a4b8 100644 --- a/ext/curl/tests/curl_copy_handle_basic_007.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_007.phpt @@ -1,10 +1,11 @@ --TEST-- Test curl_copy_handle() with simple POST --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); echo '*** Testing curl copy handle with simple POST using array as arguments ***' . "\n"; diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt index 692c2df192..cdb7de374d 100644 --- a/ext/curl/tests/curl_copy_handle_basic_008.phpt +++ b/ext/curl/tests/curl_copy_handle_basic_008.phpt @@ -1,10 +1,11 @@ --TEST-- Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); $url = "{$host}/get.php"; $ch = curl_init($url); diff --git a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt index 3a4d949e75..5e806add08 100644 --- a/ext/curl/tests/curl_file_deleted_before_curl_close.phpt +++ b/ext/curl/tests/curl_file_deleted_before_curl_close.phpt @@ -3,11 +3,13 @@ Memory corruption error if fp of just created file is closed before curl_close. --CREDITS-- Alexey Shein <confik@gmail.com> --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$ch = curl_init(getenv('PHP_CURL_HTTP_REMOTE_SERVER')); +include 'server.inc'; +$host = curl_cli_server_start(); +$ch = curl_init($host); $temp_file = dirname(__FILE__) . '/curl_file_deleted_before_curl_close.tmp'; if (file_exists($temp_file)) { diff --git a/ext/curl/tests/curl_file_upload.phpt b/ext/curl/tests/curl_file_upload.phpt index d3168e578a..3a5a78fde3 100644 --- a/ext/curl/tests/curl_file_upload.phpt +++ b/ext/curl/tests/curl_file_upload.phpt @@ -1,14 +1,8 @@ --TEST-- CURL file uploading +--INI-- --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - exit("skip curl extension not loaded"); -} -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php @@ -25,7 +19,8 @@ function testcurl($ch, $name, $mime = '', $postname = '') var_dump(curl_exec($ch)); } -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -48,6 +43,7 @@ var_dump($file->getPostFilename()); curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => $file)); var_dump(curl_exec($ch)); +curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 0); $params = array('file' => '@' . __DIR__ . '/curl_testdata1.txt'); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); var_dump(curl_exec($ch)); diff --git a/ext/curl/tests/curl_multi_getcontent_basic3.phpt b/ext/curl/tests/curl_multi_getcontent_basic3.phpt index ac2a371724..190fe9d9c0 100644 --- a/ext/curl/tests/curl_multi_getcontent_basic3.phpt +++ b/ext/curl/tests/curl_multi_getcontent_basic3.phpt @@ -4,12 +4,7 @@ Curl_multi_getcontent() basic test with different sources (local file/http) Rein Velt (rein@velt.org) #TestFest Utrecht 20090509 --SKIPIF-- -<?php -if (!extension_loaded('curl')) print 'skip need ext/curl'; -if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php //CURL_MULTI_GETCONTENT TEST @@ -19,7 +14,8 @@ if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { $ch2=curl_init(); //SET URL AND OTHER OPTIONS - $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + include 'server.inc'; + $host = curl_cli_server_start(); curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=getpost&get_param=Hello%20World"); curl_setopt($ch2, CURLOPT_URL, "file://".dirname(__FILE__). DIRECTORY_SEPARATOR . "curl_testdata2.txt"); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); diff --git a/ext/curl/tests/curl_setopt_array_basic.phpt b/ext/curl/tests/curl_setopt_array_basic.phpt index 427de7fc75..d858241b78 100644 --- a/ext/curl/tests/curl_setopt_array_basic.phpt +++ b/ext/curl/tests/curl_setopt_array_basic.phpt @@ -4,7 +4,7 @@ curl_setopt_array() function - tests setting multiple cURL options with curl_set Mattijs Hoitink mattijshoitink@gmail.com #Testfest Utrecht 2009 --SKIPIF-- -<?php if (!extension_loaded("curl")) print "skip"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php /* @@ -15,7 +15,8 @@ Mattijs Hoitink mattijshoitink@gmail.com */ // Figure out what handler to use -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); if (!empty($host)) { // Use the set Environment variable $url = "{$host}/get.php?test=get"; diff --git a/ext/curl/tests/curl_setopt_basic002.phpt b/ext/curl/tests/curl_setopt_basic002.phpt index 074158a4b3..7a11493ed2 100644 --- a/ext/curl/tests/curl_setopt_basic002.phpt +++ b/ext/curl/tests/curl_setopt_basic002.phpt @@ -4,11 +4,12 @@ curl_setopt basic tests with CURLOPT_STDERR. Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** Testing curl_setopt with CURLOPT_STDERR\n"; diff --git a/ext/curl/tests/curl_setopt_basic003.phpt b/ext/curl/tests/curl_setopt_basic003.phpt index aa225c6e33..246b83b418 100644 --- a/ext/curl/tests/curl_setopt_basic003.phpt +++ b/ext/curl/tests/curl_setopt_basic003.phpt @@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_HTTPHEADER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** curl_setopt() call with CURLOPT_HTTPHEADER\n"; diff --git a/ext/curl/tests/curl_setopt_basic004.phpt b/ext/curl/tests/curl_setopt_basic004.phpt index 97b4115e3c..ee0b4921d5 100644 --- a/ext/curl/tests/curl_setopt_basic004.phpt +++ b/ext/curl/tests/curl_setopt_basic004.phpt @@ -4,11 +4,12 @@ curl_setopt() call with CURLOPT_RETURNTRANSFER Paul Sohier #phptestfest utrecht --SKIPIF-- -<?php if (!extension_loaded("curl") || false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?> +<?php include 'skipif.inc'; ?> --FILE-- <?php -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); // start testing echo "*** curl_setopt() call with CURLOPT_RETURNTRANSFER set to 1\n"; diff --git a/ext/curl/tests/curl_version_error.phpt b/ext/curl/tests/curl_version_error.phpt index fb4793af16..a9b80c55be 100644 --- a/ext/curl/tests/curl_version_error.phpt +++ b/ext/curl/tests/curl_version_error.phpt @@ -1,14 +1,7 @@ --TEST--
Test curl_version() function : error conditions
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- die('skip - curl extension not available in this build');
-}
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
-}
-?>
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--FILE--
<?php
diff --git a/ext/curl/tests/curl_version_variation1.phpt b/ext/curl/tests/curl_version_variation1.phpt index cd912c4803..927b4ac317 100644 --- a/ext/curl/tests/curl_version_variation1.phpt +++ b/ext/curl/tests/curl_version_variation1.phpt @@ -1,14 +1,7 @@ --TEST--
Test curl_version() function : usage variations - test values for $ascii argument
--SKIPIF--
-<?php
-if (!extension_loaded("curl")) {
- echo "skip - curl extension not available in this build";
-}
-if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) {
- echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable";
-}
-?>
+<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--FILE--
<?php
diff --git a/ext/curl/tests/curl_writeheader_callback.phpt b/ext/curl/tests/curl_writeheader_callback.phpt index fa27363a41..46e0cc18ba 100644 --- a/ext/curl/tests/curl_writeheader_callback.phpt +++ b/ext/curl/tests/curl_writeheader_callback.phpt @@ -4,16 +4,9 @@ Test curl option CURLOPT_HEADERFUNCTION Mathieu Kooiman <mathieuk@gmail.com> Dutch UG, TestFest 2009, Utrecht --DESCRIPTION-- -Hit the host identified by PHP_CURL_HTTP_REMOTE_SERVER and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers specified for PHP_CURL_HTTP_REMOTE_SERVER might return different sets of headers. Just test for HTTP/1.1 200 OK. +Hit the host and determine that the headers are sent to the callback specified for CURLOPT_HEADERFUNCTION. Different test servers might return different sets of headers. Just test for HTTP/1.1 200 OK. --SKIPIF-- -<?php -if (!extension_loaded("curl")) { - echo "skip - curl extension not available in this build"; -} -if (!getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { - echo "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; -} -?> +<?php include 'skipif.inc'; ?> --FILE-- <?php @@ -23,7 +16,8 @@ function curl_header_callback($curl_handle, $data) echo $data; } -$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER'); +include 'server.inc'; +$host = curl_cli_server_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); diff --git a/ext/curl/tests/server.inc b/ext/curl/tests/server.inc new file mode 100644 index 0000000000..6d96a9850c --- /dev/null +++ b/ext/curl/tests/server.inc @@ -0,0 +1,56 @@ +<?php + +define ("PHP_CURL_SERVER_HOSTNAME", "localhost"); +define ("PHP_CURL_SERVER_PORT", 8964); +define ("PHP_CURL_SERVER_ADDRESS", PHP_CURL_SERVER_HOSTNAME.":".PHP_CURL_SERVER_PORT); + +function curl_cli_server_start() { + if(getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + return getenv('PHP_CURL_HTTP_REMOTE_SERVER'); + } + + $php_executable = getenv('TEST_PHP_EXECUTABLE'); + $doc_root = __DIR__; + $router = "responder/get.php"; + + $descriptorspec = array( + 0 => STDIN, + 1 => STDOUT, + 2 => STDERR, + ); + + if (substr(PHP_OS, 0, 3) == 'WIN') { + $cmd = "{$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS; + $cmd .= " {$router}"; + $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); + } else { + $cmd = "exec {$php_executable} -t {$doc_root} -n -S " . PHP_CURL_SERVER_ADDRESS; + $cmd .= " {$router}"; + $cmd .= " 2>/dev/null"; + + $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); + } + + // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' + // it might not be listening yet...need to wait until fsockopen() call returns + $i = 0; + while (($i++ < 30) && !($fp = @fsockopen(PHP_CURL_SERVER_HOSTNAME, PHP_CURL_SERVER_PORT))) { + usleep(10000); + } + + if ($fp) { + fclose($fp); + } + + register_shutdown_function( + function($handle) use($router) { + proc_terminate($handle); + }, + $handle + ); + // don't bother sleeping, server is already up + // server can take a variable amount of time to be up, so just sleeping a guessed amount of time + // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass + // sleeping doesn't work. + return PHP_CURL_SERVER_ADDRESS; +} diff --git a/ext/curl/tests/skipif.inc b/ext/curl/tests/skipif.inc new file mode 100644 index 0000000000..62b252bcd1 --- /dev/null +++ b/ext/curl/tests/skipif.inc @@ -0,0 +1,7 @@ +<?php + if (!extension_loaded("curl")) exit("skip curl extension not loaded"); + if(false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) { + if (php_sapi_name() != "cli") { + die("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined"); + } + } |