I’m using PHPUnit to try to unit test some PHP files that are part of a web application I’m developing. I’ve got a WAMP server set up, and have set my php.ini file to have the curl extension installed. I’ve verified it’s installed by checking phpinfo(), and curl does have a config section on the page, indicating it’s installed.
When I run my entire web application starting from the index page, this php page I’m trying to test finds the curl_init() function without a problem.
When I run my unit test on the file, however, the it gives me the following error:
PHP Fatal error: Call to undefined function curl_init() in ...
Like I said, the file that calls curl_init() works great when run in the context of the whole application, but can’t find it when it’s being run alone by my PHPUnit tests. Does anyone know why this is happening? Does PHPUnit not know how to find the PHP extensions installed on my WAMP server?
You need to add the Curl libraries to the command line PHP.ini.
You can probably just copy the file
C:\wamp\bin\apache\Apache2.2.x\bin\php.initoc:\wamp\bin\php\php5.3.10\php.ini(adjust for the actual directories on your system).