PHP致命错误:尝试运行测试样本时找不到类"WP_UnitTestCase" [英] PHP Fatal error: Class 'WP_UnitTestCase' not found when trying to run test-sample
问题描述
我正在尝试使用phpunit使用我的wordpress插件初始化php单元测试.我在Windows上运行xampp.如果有任何区别,我的xampp安装也位于我的E:驱动器上.我将跟随本教程:
I am trying to initialize php unit testing with my wordpress plugin using phpunit. I am running xampp on windows. My xampp installation is also on my E: drive if that makes any difference. I am following along with this tutorial:
https://www.smashingmagazine.com/2017/12/12自动化测试wordpress-plugins-phpunit/
我已经到了跑步的地方
install-wp-tests.sh wordpress_test root '' localhost latest
我运行它,它弹出并迅速关闭,所以我不知道它是否真的起作用.然后,我尝试运行
I run that and it pops up and closes quickly, so I don't know if it is really working or not. I then try to run
phpunit tests/test-sample.php
然后我得到:
PHP Fatal error: Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11
Fatal error: Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11
我认为这意味着install-wp-test.sh不能正确安装,并且缺少这些类.有什么想法吗?
I assume that means the install-wp-test.sh isn't installing correctly and it is missing those classes. Any ideas?
推荐答案
最终需要为Windows安装SVN.还必须将mysqladmin.exe路径添加到PATH环境变量中.然后最后需要这个:
Ended up needing to install SVN for windows. Also had to add the mysqladmin.exe path to the PATH environment variable. Then finally needed this :
经过这三个小时!我知道它能正常工作!
And after all that and 3 hours! I got it to work correctly!
希望这对其他人有帮助.
Hope this helps someone else.
这篇关于PHP致命错误:尝试运行测试样本时找不到类"WP_UnitTestCase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!