gpt4 book ai didi

php - 如何在 OSX 10.8.4 下使用适用于 Yii 和 Netbeans 的 MAMP 2.1.4 安装 phpunit?

转载 作者:行者123 更新时间:2023-12-02 21:52:07 25 4
gpt4 key购买 nike

我想在运行 OSX 10.8.4 和 MAMP Pro 以及 PHP 5.4.1 的本地机器上使用 phpunit 测试。此外,我想将它用于 Yii 和我的 IDE Netbeans。

我通过 pear 阅读了一些类似这种方法的教程或通过composer 。我什至试图看起来像人们在 windows 上做的那样- 没有成功。

我的方法总是会导致类似的错误

PHP Warning: include(): Failed opening 'PHP_Invoker.php'

PHP Warning: include(): Failed opening 'PHPUnit_Extensions_Database_TestCase.php'

PHP Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php'

Failed opening required 'PHPUnit/Extensions/SeleniumTestCase.php'

PHP Fatal error: Class 'CTestCase' not found

或者根本没有找到 phpunit。

最佳答案

但最终我找到了一个教程,给了我一个良好的开端。经过更多的研究,我也找到了上面发布的问题的解决方案。

在这里,我只想分享我的步骤以及您可以通过以使其运行的所有链接:)

第一步是遵循 Zank's tutorial

但是在我执行了他的步骤之后,我遇到了一些错误。因为您必须安装的模块列表不完整。当我尝试运行测试时,最终出现以下错误:

PHP Warning: include(): Failed opening 'PHP_Invoker.php'

PHP Warning: include(): Failed opening 'PHPUnit_Extensions_Database_TestCase.php'

PHP Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php'

第二步

所以我用谷歌搜索并发现我也必须执行以下操作:

pear install phpunit/PHPUnit_Story

pear install phpunit/DbUnit

但是“调用者”问题并不那么容易。因为当你尝试时

pear install phpunit/PHP_Invoker

这会导致类似的错误

phpunit/PHP_Invoker requires PHP extension "pcntl"

安装这个扩展到 MAMP 是一件很痛苦的事情。但我found这是这个解决方案:

  • went to pear.phpunit.de
  • manually downloaded PHP_Invoker utility class
  • unzipped the file on my daughter's mac (I'm running Windows)
  • put the "Invoker" directory under C:\xampp\php\pear\PHP
  • put the "Invoker.php" file under C:\xampp\php\pear\PHP

对于您的 MAMP 安装,路径应该类似于“/Applications/MAMP/bin/php/php5.4.10/lib” - 此外,我必须将“Invoker.php”重命名为“PHP_Invoker” .php'。

第三步

在命令行上,现在一切都应该可以工作了 - 编写一个测试并尝试一下,就像第一步中链接的 Zank 教程一样。但是 Netbeans 呢?就像在 Zank 的教程中一样,我输入了 phpunit 路径,然后右键单击我的一个测试并选择“运行测试” - 错误!

PHP Fatal error: Class 'CTestCase' not found

解决办法可以找到here 。当您没有右键单击“phpunit.xml”所在的文件夹时,就会发生这种情况。但为了避免这种情况,您可以执行以下操作:

  • 只需右键单击其中包含“phpunit.xml”的文件夹即可“运行测试”。
  • 或者进入测试属性 -> PHPUnit 并选中“使用 XML 配置”复选框并选择“phpunit.xml”文件

就是这样!

这里有一些也很有趣的链接:

关于php - 如何在 OSX 10.8.4 下使用适用于 Yii 和 Netbeans 的 MAMP 2.1.4 安装 phpunit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18386208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com