Maciej Strączkowski
Maciej Strączkowski

Reputation: 111

phpUnit Testing curl operations

I have class and I'm using it to curl operations (sending post data, getting source of website etc).

Now I want to make unit tests to it, but I dont have idea how I can test it ?

Example usage of my class:

$curl = new Curl();
$curl->setUrl('http://example.php');
$curl->setReturn(true);
$source = $curl->execute();

Have you any advices for me ?

Upvotes: 1

Views: 2953

Answers (1)

cweiske
cweiske

Reputation: 31078

You could use an abstraction to curl, namely HTTP_Request2. During unit tests, you don't use the curl adapter but the mock adapter.

The library is stable and unit-tested, so you don't have to test your curl usage anymore, but can safely work with the mock data.

Upvotes: 3

Related Questions