qa:temp:ext:curl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
qa:temp:ext:curl [2009/05/09 10:29] – created pajoyeqa:temp:ext:curl [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-Place to document how to test cURL+====== Testing the cURL extension ====== 
 + 
 +How to test the cURL extension. 
 + 
 +===== With a webserver ===== 
 +The cURL extensions tests can be run with the help of both a file on a webserver and a ftp server that can be reached by the machine the tests are run on. Environmental variables needs to be set as follows (on Unix):\\ 
 +<code> 
 +export PHP_CURL_HTTP_REMOTE_SERVER=http://www.example.com 
 +export PHP_CURL_FTP_REMOTE_SERVER="ftp.example.net"; 
 +export PHP_CURL_FTP_REMOTE_USER="ftpusername"; 
 +export PHP_CURL_FTP_REMOTE_PASSWD="ftppassword"; 
 +</code> 
 +Where http://www.example.com is the url to the host providing the test file. If the variable is not set the tests will assume you have webserver unning on the machine the tests are run on. 
 + 
 +The ''get.php'' file used for testing can be found in the ''ext/curl/tests/responder'' directory and needs to be copied to the root of the webserver that is going to be used for testing. 
 + 
 +===== With a local file ===== 
 +Some cURL tests work with a local file. The ''PHP_CURL_HTTP_REMOTE_SERVER'' variable can be set to a local file to get the reponse data from. 
 + 
 +The following piece of code is used to make sure a file is always present. 
 +<code> 
 +// Figure out what handler to use 
 +if(!empty($_ENV['PHP_CURL_HTTP_REMOTE_SERVER'])) { 
 +    // Use the set Environment variable 
 +    $host = $_ENV['PHP_CURL_HTTP_REMOTE_SERVER']; 
 +    $url = "{$host}/get.php?test=get"; 
 +} else { 
 +    // Create a temporary file for the test 
 +    $tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE'); 
 +    $url = 'file://'. $tempname; 
 +    // add the test data to the file 
 +    file_put_contents($tempname, "Hello World!\nHello World!"); 
 +
 + 
 +/* .. your test .. */ 
 + 
 +// Cleanup 
 +isset( $tempname ) and unlink( $tempname ); 
 +</code> 
 + 
 +When the ''PHP_CURL_HTTP_REMOTE_SERVER'' variable isn't set a temporary file is created and the data needed for the test is put in there.
qa/temp/ext/curl.1241864979.txt.gz · Last modified: 2017/09/22 13:28 (external edit)