我正在使用 codeception,当我尝试检查 dbconnection 时它显示错误:
> DEPRECATION: Calling the
> "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()"
> method with the event name as first argument is deprecated since
> Symfony 4.3, pass it second and provide the event object first
> instead.
> C:\xampp\htdocs\affiliate_codeception\codeception\vendor\symfony\event-dispatcher\EventDispatcher.php:58"
我该如何解决这个问题?
<?php
class adminTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testSomeFeature()
{
}
public function tryToTest(UnitTester $I)
{
$I->amConnectedToDatabase('testdb');
//$I->seeInDatabase('users', ['name' => 'Davert', 'email' => 'davert@mail.com']);
}
}
最佳答案
更改vendor/codeception/phpunit-wrapper/src/Listener.php
中的代码:
搜索
dispatcher->dispatch(
对于它们中的每一个,交换第一个和第二个参数。
例如,第一次出现的是:
public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
{
$this->dispatcher->dispatch('suite.start', new SuiteEvent($suite));
}
将其更改为:
public function startTestSuite(\PHPUnit\Framework\TestSuite $suite)
{
$this->dispatcher->dispatch(new SuiteEvent($suite), 'suite.start');
}
关于codeception - 如何修复 codeception 中的这个 DEPRECATION 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56395956/