【问题标题】:PHP Unit test Error - PHPUnit_Util_DeprecatedFeature_LoggerPHP 单元测试错误 - PHPUnit_Util_DeprecatedFeature_Logger
【发布时间】:2015-01-12 00:15:59
【问题描述】:

我已经用作曲家安装了 PHPUnit。我在 composer.json 中有以下行

  "require-dev": {
    "phpunit/phpunit": "~4.3"
},  

当我运行我的测试用例时,我遇到了错误。我已经搜索过这个错误,但在网络上找不到可能的相关解决方案:

        Vishal@VISHAL-PC c:\xampp\htdocs\V4\test\Core

        phpunit ResponseTest 


        PHPUnit 4.3.5 by Sebastian Bergmann.


       Fatal error: Class PHPUnit_Util_DeprecatedFeature_Logger contains 1 abstract met
       hod and must therefore be declared abstract or implement the remaining methods (
      PHPUnit_Framework_TestListener::addRiskyTest) in C:\xampp\php\pear\PHPUnit\Util\
      DeprecatedFeature\Logger.php on line 201

我不知道这是从哪里来的。任何建议,链接或评论将不胜感激。

【问题讨论】:

  • 确保这个文件 C:\xampp\php\pear\PHPUnit\Util\DeprecatedFeature\Logger.php 有一个抽象方法,如果有,请尝试更改为接近 4.3.5 的另一个版本。
  • 感谢@Pradeep!似乎它在 Loger.php 中没有抽象方法并添加了一个。它现在正在工作。

标签: php unit-testing web phpunit composer-php


【解决方案1】:

PHPUnit_Util_DeprecatedFeature_Logger 类在 PHPUnit 4.2 中被移除。如果您安装的 PHPUnit 4.3 尝试使用该类,这意味着您的安装以某种方式搞砸了。

【讨论】:

    【解决方案2】:

    您仍然可以从之前安装的位置继续运行您的 phpunit。要从 composer 运行它,请将以下别名添加到您的 .bashrc 文件中

    sudo nano ~/.bashrc
    
    alias phpunit="/{path_to_project}/vendor/bin/phpunit"
    

    【讨论】:

      猜你喜欢
      • 2011-06-12
      • 2014-03-14
      • 2014-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-24
      • 2015-06-12
      相关资源
      最近更新 更多