PHPUnit 7.2 和 Codeception 2.4 不兼容

PHPUnit 7.2 and Codeception 2.4 are incompatible

正在尝试使用 Laravel 框架 5.6

安装 CodeCeption

我遇到了这个错误。

我安装的步骤是 1. 作曲家需要 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 一起使用吗?

在 Codeception/Test/Unit.php 第 133 行中,将 getDependencies 函数更改为数组 return 类型。 : 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;
}

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


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

2.4.5
  • Fixed PHPUnit 7.2 compatibility.
  • Introduced RunBefore extension to execute scripts before running tests. See #5049 by @aashmelev.
  • [Db] Added two options for MySQL by @bangertz
    • ssl_cipher - list of one or more permissible ciphers to use for SSL encryption
    • ssl_verify_server_cert - disables certificate CN verification
  • [Db] Always disconnect before connect when reconnect is set. By @ashnazg
  • [Db] More explicit PDO closing upon destruction and close opened transactions by @ashnazg.
  • [Recorder Extension] Improved error logging by @OneEyedSpaceFish. See #5101
  • [Lumen] Fixed file uploads via REST module. By @retnek.
  • Fixed: function getMetadata() may not exist, results in fatal error. See #4913 by @marcovtwout