今天早上,我意识到 Xampp 提供的 PHPUnit 版本已经被弃用了很长一段时间...... . 版本 3.7.21。安装在 Xampp 中,但实际版本(在撰写本文时)是 6.0.13。
我尝试了一些在谷歌上提出的解决方案(所有旧的 5 年+解决方案),包括
- https://wehuberconsultingllc.com/wordpress/2007/08/18/updating-phpunit-on-xampp/
- How to configure PhpUnit in Xampp?
- http://www.righthandedmonkey.com/2012/09/setting-up-phpunit-with-xampp.html
- http://forum.kohanaframework.org/discussion/7346/installing-phpunit-on-windows-xampp/p1
- ...
无论如何,pear 似乎都不是一个可行的解决方案。有没有一种简单的方法可以在 Xampp 中更新 PHPUnit?
最佳答案
其实只要简单三步就可以更新:
- 在此处下载最新版本的 PHPUnit: https://phpunit.de/index.html
- 将“phpunit.phar”复制到“C:\xampp\php”。
- 在文件“phpunit.bat”中,更新以下行:
"%PHPBIN%""C:\xampp\php\phpunit"%*
到:"%PHPBIN%""C:\xampp\php\phpunit.phar"%
*
您不需要重新启动 apache。
附加说明:在您的测试中,您需要将:phpunit_framework_testcase
替换为:TestCase
并包括:在测试文件的顶部使用 PHPUnit\Framework\TestCase
。
当然,测试套件在我的生产服务器上仍然兼容(centos7,按照官方文档在 Linux 上更新 https://phpunit.de/getting-started.html)。
关于php - 更新 PHPunit Xampp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43188374/