Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeepCopy::recursiveCopy exception when i run codeception with yii2 framework

When run codeception i got a lots fo errors: DeepCopy\DeepCopy::recursiveCopy.

This is a problem so confuse me!

  1. I use codeception play well when i have only 4 unit test case: enter image description here
  2. When i still full up the unit test case story happen..
  3. There is 5 unit test in my test class then i got this: enter image description here

Here is the code :

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: i use xdebug to trace the problem found that when the function specifyCloneProperties deep copy the unitTester the php script down.

like image 322
micky chen Avatar asked Dec 01 '25 15:12

micky chen


1 Answers

You can turn off deep clone in your bootstrap.php file:

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

Or turn on/off in the test. It's also increased performance of your tests.

like image 61
Onedev_Link Avatar answered Dec 04 '25 06:12

Onedev_Link



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!