Олег Павлов
Олег Павлов

Reputation: 31

How to use Stub::update in Codeception?

I writing tests with Codeception framework. I am trying to use \Codeception\Stub::update for update method in existing stub, but it isn't work.

$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',
            ]
        ]);

When i use getFields method i see old NAME "First Test User". How to use Stub::update correctly?

Upvotes: 3

Views: 165

Answers (1)

Kolyunya
Kolyunya

Reputation: 6240

Seems like this is a bug. Does not work for me either.

I worked around this issue by just recreating the stub from scratch.

Upvotes: 1

Related Questions