使用yii2 framework

时间:2015-10-26 04:23:26

标签: unit-testing yii2 codeception

当运行代码时,我得到了很多错误:DeepCopy \ DeepCopy :: recursiveCopy。

这是一个让我困惑的问题!

  1. 当我只有4个单元测试用例时,我使用代码编辑很好:enter image description here
  2. 当我还在装满单元测试案例的时候......
  3. 我的测试课中有5个单元测试,然后我得到了这个:enter image description here
  4. 以下是代码:

    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脚本时。

1 个答案:

答案 0 :(得分:6)

您可以在bootstrap.php文件中turn off深度克隆:

<?php
// disable deep cloning of properties inside specify block
\Codeception\Specify\Config::setDeepClone(false);
?>

或打开/关闭in the test。它也提高了测试的性能。