Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit - Call to undefined function curl_init() error

Tags:

php

curl

phpunit

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?

like image 866
dsw88 Avatar asked Aug 15 '26 05:08

dsw88


1 Answers

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.ini to c:\wamp\bin\php\php5.3.10\php.ini (adjust for the actual directories on your system).

like image 119
AndrewR Avatar answered Aug 16 '26 20:08

AndrewR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!