Wordpress phpunit 4.07未安装php文件

Wordpress phpunit 4.07未安装php文件,wordpress,unit-testing,phpunit,Wordpress,Unit Testing,Phpunit,在过去的24小时里,我一直在互联网上寻找解决我问题的方法,我使用的是ubuntu 12.04LTS。当我使用wordpress测试套件运行测试时,我得到 "PHP Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /home/anver/mybook/myweb/wordpress-tests/includes/bootstrap.php on lin

在过去的24小时里,我一直在互联网上寻找解决我问题的方法,我使用的是ubuntu 12.04LTS。当我使用wordpress测试套件运行测试时,我得到

"PHP Warning:  require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /home/anver/mybook/myweb/wordpress-tests/includes/bootstrap.php on line 7
PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/share/php') in /home/anver/mybook/myweb/wordpress-tests/includes/bootstrap.php on line 7" 
我知道系统无法找到Autoload.php文件。我检查了pear配置,以使用

pear config-show | grep 'php_dir' 
所以我得到了

PEAR directory php_dir /usr/share/php
我将此路径添加到php.ini includes路径中,以确保使用的是正确的php.ini文件

php --info | grep 'onfiguration'
我安装了phpunit

sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover pear.phpunit.de
sudo pear update-channels
sudo pear upgrade --alldeps
sudo pear install --alldeps phpunit/PHPUnit
一切都已成功安装,当我运行时

phpunit --version
我得到了塞巴斯蒂安·伯格曼的PHPUnit 4.0.7

问题是,当我将cd放入/usr/share/php时,没有一个名为PHPUnit的目录,其中包含所有php文件和自动加载程序。因此,我尝试手动创建目录并安装它,但仍然没有将任何php文件放入目录,我还尝试将目录权限添加到777,但这也不起作用

我已经做了几乎所有的事情,比如从系统中完全删除pear并重新安装了几次,删除了phpunit并重新安装了几次,但是没有运气


有人能帮忙吗?

我在网上绞尽脑汁了好几个小时,终于找到了解决办法

首先,wordpress官方单元测试框架没有更新为使用最新的phpunit php代码。所以我所做的就是使用pear中最新的phpunit二进制文件,并使用git存储库中的旧php包。下面解释的步骤

  • 使用pear安装本文撰写时最新的phpunit 4.07

  • 将zip文件下载到主目录并解压缩

  • 将名为PHPUnit的目录复制到/usr/share/php 根据您的linux发行版而有所不同

  • chmod将dir改为755

  • sudopear安装phpunit/PHP\u CodeCoverage

  • sudopear安装

  • phpunit/PHP_定时器

  • sudopear安装phpunit/phpunit\u MockObject

    要获取phpunit的所有可用pear扩展的列表,可以使用 sudo pear list all-c phpunit

  • 现在您可以转到wordpress测试目录并运行phpunit,现在一切都应该正常了。享受吧!如果你有任何问题,请告诉我