【发布时间】:2015-08-29 10:34:50
【问题描述】:
我正在尝试为我的 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 文件夹添加到路径中,但是对于应该将其设置到哪里有一个心理障碍?
【问题讨论】:
-
这可能最好在WordPress Development SE site上询问。
-
你应该克隆trunk/tests而不是tests/trunk。它有所不同,因为测试/主干已经过时,不再维护。
标签: wordpress phpunit composer-php