我们试图在反向运行时修复现有的测试用例。我们最近将PHPUnit更新为PHPUnit 7.3 (参考文献:https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-7.3.md)
错误:
未定义索引:日志
当我在--order-by=reverse中运行测试时,下面的一行显示了错误。
$GLOBALS['log']->error(__METHOD__ . ": Not found");我试图通过添加setUp()函数来修复这个问题,方法如下:
protected function setUp()
{
$GLOBALS['log'] = '';
}
Error: Call to a member function error() on string我不知道如何编写这个错误,因为每个函数都有不同的错误日志消息。
类似职能:
$GLOBALS['log']->debug(__METHOD__ . $message);如有任何建议,将不胜感激。谢谢。
发布于 2018-08-29 06:11:39
找到答案
protected function setUp()
{
$GLOBALS['log'] = $this
->getMockBuilder('LoggerTemplate')
->setMethods(array('log', 'debug'))
->getMock();
}
protected function tearDown()
{
unset($GLOBALS['log']);
}希望这能帮到别人!
https://stackoverflow.com/questions/52036452
复制相似问题