【问题标题】:Is there an equivalent to returnArgument in Mockery?Mockery 中是否有与 returnArgument 等价的东西?
【发布时间】:2014-10-14 08:40:22
【问题描述】:

我正在寻找与此等效的:

$stub->expects($this->any())
     ->method('doSomething')
     ->will($this->returnArgument(0));

见:How to return the argument of a mocked method?

Mockery 里面有类似的吗?

【问题讨论】:

    标签: php unit-testing phpunit mockery


    【解决方案1】:

    用闭包试试

    Mockery::mock('SomeClass')
        ->shouldReceive('doSomething')
        ->andReturnUsing(function($arg) {
            return $arg;
        })
        ->mock();
    

    【讨论】:

      猜你喜欢
      • 2022-01-10
      • 2018-05-26
      • 2012-12-30
      • 2020-07-21
      • 1970-01-01
      • 2021-09-17
      • 2018-06-01
      • 2018-01-07
      • 2011-11-16
      相关资源
      最近更新 更多