【问题标题】:PHPUnit 7.2 and Codeception 2.4 are incompatiblePHPUnit 7.2 和 Codeception 2.4 不兼容
【发布时间】:2019-01-08 12:19:09
【问题描述】:

尝试使用 Laravel 框架 5.6 安装 CodeCeption

我收到此错误。

我安装的步骤是 1.composer需要codeception/codeception --dev 2. php ./vendor/bin/codecept bootstrap

我得到的错误是

Fatal error: Declaration of Codeception\Test\Unit::getDependencies() must be compatible with PHPUnit\Framework\TestCase::getDependencies(): array in /vendor/codeception/codeception/src/Codeception/Test/Unit.php on line 14

有人能告诉我如何解决这个问题或降级并让它与 Laravel 5.6 一起工作吗?

【问题讨论】:

    标签: php laravel phpunit codeception


    【解决方案1】:

    这只是fixed in codeception/codeception version 2.4.5,所以运行composer update,错误应该不再发生。


    来自更新日志(强调我的):

    2.4.5
    • 修复了 PHPUnit 7.2 的兼容性。
    • 引入了 RunBefore 扩展以在运行测试之前执行脚本。请参阅@aashmelev 的#5049。
    • [Db] 为 MySQL 添加了两个选项 @bangertz
      • ssl_cipher - 一个或多个允许用于 SSL 加密的密码列表
      • ssl_verify_server_cert - 禁用证书 CN 验证
    • [Db] 设置reconnect 时,始终先断开连接再连接。通过@ashnazg
    • [Db] 更明确的 PDO 在销毁时关闭并关闭由@ashnazg 打开的事务。
    • [Recorder Extension] 改进了@OneEyedSpaceFish 的错误记录。请参阅 #5101
    • [Lumen] 修复了通过 REST 模块上传文件的问题。由@retnek 提供。
    • 已修复:函数 getMetadata() 可能不存在,导致致命错误。参见@marcovtwout 的#4913

    【讨论】:

      【解决方案2】:

      在 Codeception/Test/Unit.php 第 133 行中,将 getDependencies 函数更改为具有数组返回类型。 : array

      更改后的 getDependencies 函数应如下所示。

      public function getDependencies(): array
      {
          $names = [];
          foreach ($this->getMetadata()->getDependencies() as $required) {
              if ((strpos($required, ':') === false) and method_exists($this, $required)) {
                  $required = get_class($this) . ":$required";
              }
              $names[] = $required;
          }
          return $names;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-16
        • 1970-01-01
        • 2014-12-09
        • 1970-01-01
        • 2017-04-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多