mic*_*hen 3 unit-testing yii2 codeception
当运行代码时,我得到了很多错误: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,
],
]
],
]]);
}
Run Code Online (Sandbox Code Playgroud)
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'=>类Codeception\Scenario {protected $ test = class tests\codeception\frontend\service\ConfigServiceTest {...}; protected $ steps = array(...);
xdebug:我用xdebug跟踪发现的问题,当函数specifyCloneProperties深度复制unitTester的php脚本时.
您可以在文件中关闭深度克隆bootstrap.php:
<?php
// disable deep cloning of properties inside specify block
\Codeception\Specify\Config::setDeepClone(false);
?>
Run Code Online (Sandbox Code Playgroud)
或者在测试中打开/关闭.它还提高了测试的性能.
| 归档时间: |
|
| 查看次数: |
537 次 |
| 最近记录: |