Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Codeception中使用Stub::update?_Php_Unit Testing_Phpunit_Codeception - Fatal编程技术网

Php 如何在Codeception中使用Stub::update?

Php 如何在Codeception中使用Stub::update?,php,unit-testing,phpunit,codeception,Php,Unit Testing,Phpunit,Codeception,我使用Codeception框架编写测试。 我试图在现有存根中使用\Codeception\Stub::update for update方法,但它不起作用 $this->userServiceStub = Stub::make(User::class, [ 'getService' => function() use ($serviceStub) { return $serviceStub; },

我使用Codeception框架编写测试。 我试图在现有存根中使用\Codeception\Stub::update for update方法,但它不起作用

$this->userServiceStub = Stub::make(User::class, [
            'getService' => function() use ($serviceStub) {
                return $serviceStub;
            },
            'getFields' => [
                'ID' => 1234,
                'NAME' => 'First Test User',
            ],
        ]);

$this->userServiceStub = Stub::update($this->userServiceStub, [
            'getFields' => [
                'ID' => 1234,
                'NAME' => 'Second Test User',
            ]
        ]);
当我使用getFields方法时,我看到了旧名称“FirstTestUser”。如何正确使用Stub::update