argamentor
argamentor

Reputation: 148

Is there an equivalent to returnArgument in Mockery?

I'm looking for an equivalent to this:

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

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

Is there anything similar to this in Mockery?

Upvotes: 1

Views: 587

Answers (1)

Bram Gerritsen
Bram Gerritsen

Reputation: 7238

Try it using a closure

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

Upvotes: 4

Related Questions