PHPUnit - 调用未定义的函数curl_init()错误 [英] PHPUnit - Call to undefined function curl_init() error

查看:191
本文介绍了PHPUnit - 调用未定义的函数curl_init()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHPUnit尝试单元测试一些PHP文件,这些文件是我开发的Web应用程序的一部分。我有一个WAMP服务器设置,并已设置我的php.ini文件安装curl扩展。我已经通过检查phpinfo()验证它的安装,并且curl在页面上有一个配置部分,指示它已安装。

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.

当我运行我的整个Web应用程序从索引页,这个php页面我试图测试发现curl_init()函数没有问题。

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

就像我说的,但是当它被我的PHPUnit测试单独运行时,找不到它。有人知道为什么这种情况发生吗? PHPUnit不知道如何找到我的WAMP服务器上安装的PHP扩展。

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?

推荐答案

您需要将Curl库添加到命令行PHP.ini。

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

您可以只是复制文件 C:\wamp\bin\apache\Apache2.2 .x\bin\php.ini c:\wamp\bin\php\php5.3.10\\ pp.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).

这篇关于PHPUnit - 调用未定义的函数curl_init()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆