我正在尝试为我的wordpress插件编写一个php单元测试,并且一直在关注writing-wordpress-plugin-unit-tests教程。我在本地克隆了'core.trac.wordpress.org/browser/tests/trunk/includes'
我已经通过PHAR机制安装了phpunit,如下所述:https://phpunit.de/manual/current/en/installation.html#installation.requirements。我也有一个composer.json配置
[14:11:04@~]$ phpunit --version
PHPUnit 4.7.3 by Sebastian Bergmann and contributors.
在我的/etc/php.ini文件中我有
include_path="."
当我运行我的phpunit时,我收到此错误
[14:18:07@bhaawp]$ phpunit
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.') in /Users/pauloconnell/projects/bhaawp/wp-phpunit/bootstrap.php on line 7
bootstrap.php文件包含
<?php
/**
* Installs WordPress for running the tests and loads WordPress and the test libraries
*/
require_once 'PHPUnit/Autoload.php';
我想我需要将phpunit文件夹添加到路径中,但是我应该设置一个mental block来设置它的位置?
答案 0 :(得分:2)
PHPUnit没有名为PHPUnit/Autoload.php
的文件(不再)。
如果Wordpress&#39;测试套件和/或测试Wordpress插件的最佳实践提及/使用该文件然后这将表明Wordpress依赖于过时版本的PHPUnit。
答案 1 :(得分:1)
您需要克隆https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/。您正在克隆的那个已经过时了,不再更新。
您会在new bootstrap.php中看到该行不再存在。