小编One*_*ink的帖子

调用参数类型与声明不兼容

Phpstorm有检查:Invocation parameter types are not compatible with declared.

我很惊讶php允许使用基类型作为子类型.

interface Base
{
    public function getId();
}

interface Child extends Base
{

}

interface SecondChildType extends Base
{

}

class ChildImpl implements Child
{
    public function getId()
    {
        return 1;
    }
}

class SecondChildTypeImpl implements SecondChildType
{
    public function getId()
    {
        return 2;
    }
}

class BaseService
{
    public function process(Base $base)
    {
        $childService = new ChildService($base);

        return $childService->process($base); //Invocation parameter types are not compatible with declared
    }
} …
Run Code Online (Sandbox Code Playgroud)

php

8
推荐指数
1
解决办法
5638
查看次数

当我使用yii2框架运行codeception时,DeepCopy :: recursiveCopy异常

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

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

  1. 当我只有4个单元测试用例时,我使用代码发挥很好: 在此输入图像描述
  2. 当我仍然完整的单位测试案例故事发生..
  3. 在我的测试课中有5个单元测试然后我得到了这个: 在此输入图像描述

这是代码:

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跟踪发现的问题,当函数 …

unit-testing yii2 codeception

3
推荐指数
1
解决办法
537
查看次数

标签 统计

codeception ×1

php ×1

unit-testing ×1

yii2 ×1