qa:temp:ext:curl

This is an old revision of the document!


Testing the cURL extension

How to test the cURL extension.

With a webserver

The cURL extensions tests can be run with the help of a file on a webserver that can be reached by the machine the tests are run on. An environmental variable pointing to the host needs to be set as follows (on Unix):

export PHP_CURL_HTTP_REMOTE_SERVER=http://www.example.com

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 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

Proposal for file fallback.

// 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!");
}
qa/temp/ext/curl.1241878896.txt.gz · Last modified: 2017/09/22 13:28 (external edit)