PHPUnit 7.2 and Codeception 2.4 are incompatible

扶醉桌前 提交于 2019-12-11 19:13:58

问题


Trying to install CodeCeption with Laravel framework 5.6

I am getting this error.

Steps i followed to install are 1. composer require codeception/codeception --dev 2. php ./vendor/bin/codecept bootstrap

The error i am getting is

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

Can someone tell how to fix this or downgrade and get it work with Laravel 5.6?


回答1:


In Codeception/Test/Unit.php line no 133, change the getDependencies function to have a array return type. : array

After the change the getDependencies function should look like this.

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;
}



回答2:


This was just fixed in codeception/codeception version 2.4.5, so run composer update, and the error should no longer be happening.


From the changelog (emphasis mine):

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


来源:https://stackoverflow.com/questions/51624616/phpunit-7-2-and-codeception-2-4-are-incompatible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!