当运行代码时,我得到了很多错误:DeepCopy \ DeepCopy :: recursiveCopy。
这是一个让我困惑的问题!
以下是代码:
public function testGetComplexItemNeeds() {
$this->specify('[getComplexItemNeeds] : ', function($expected) {
$actual = \common\services\ConfigService::getComplexItemNeeds('300001');
expect('getComplexItemNeeds', $actual)->equals($expected);
}, ['examples' => [
[0 => [
'gold' => 1,
'list' => [
300018 => 1,
],
]
],
]]);
}
php_error.log:
PHP 195. DeepCopy \ DeepCopy :: copyArray($ array = array('0000000025e4802e0000000050ab4f11'=> class tests \ codeception \ frontend \ UnitTester {protected $ scenario = class Codeception \ Scenario {...}; protected $ friends = array(...)},'0000000025e480490000000050ab4f11'=> class Codeception \ Scenario {protected $ test = class tests \ codeception \ frontend \ service \ ConfigServiceTest {...}; protected $ steps = array(...) ;
Xdebug的:
我使用xdebug来跟踪发现的问题,当函数specifyCloneProperties
深度复制unitTester的php脚本时。
答案 0 :(得分:6)
您可以在bootstrap.php
文件中turn off深度克隆:
<?php
// disable deep cloning of properties inside specify block
\Codeception\Specify\Config::setDeepClone(false);
?>
或打开/关闭in the test。它也提高了测试的性能。