【问题标题】:How to use Stub::update in Codeception?如何在 Codeception 中使用 Stub::update?
【发布时间】:2020-10-06 21:45:24
【问题描述】:

我使用 Codeception 框架编写测试。 我正在尝试在现有存根中使用 \Codeception\Stub::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 方法时,我看到旧名称“第一个测试用户”。如何正确使用 Stub::update?

【问题讨论】:

    标签: php unit-testing phpunit codeception


    【解决方案1】:

    好像这是bug。也不适合我。

    我只是通过从头开始重新创建存根来解决这个问题。

    【讨论】:

      猜你喜欢
      • 2016-03-16
      • 2014-11-26
      • 2012-07-19
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多