PHPUnit - call undefined function curl_init ()

I am using PHPUnit to try and unit test some PHP files that are part of a web application that I am developing. I have a WAMP server configured and I have a php.ini file installed to install the curl extension. I tested it by setting the phpinfo () check and curl has a config section on the page indicating that it is installed.

When I run the entire web application starting from the index page, this php page I am trying to check finds the curl_init () function without issue.

However, when I run my unit test file on a file, it throws the following error:

PHP Fatal error: Call to undefined function curl_init() in ...


As I said, the file that calls curl_init () works fine when run in the context of the whole application, but cannot find it when it is only executed in my PHPUnit tests. Does anyone know why this is happening? PHPUnit doesn't know how to find PHP extensions installed on my WAMP server?


source to share

2 answers

You need to add Curl libraries to PHP.ini command line.

You can most likely copy the file C:\wamp\bin\apache\Apache2.2.x\bin\php.ini

to c:\wamp\bin\php\php5.3.10\php.ini

(adjust the actual directories on your system).



Open the file c:\wamp\bin\php\php5.x.x\php.ini

and find:



Just uncomment this by removing the semicolon, for example:



and save the file.



All Articles