Return Argument from PHPUnit Test as part of an array

Viewed 797

I want to return an array from this mocked method and I want it to contain one of the arguments originally passed to the method.

The code below runs but instead of data having the original argument value it's an object of type

PHPUnit_Framework_MockObject_Stub_ReturnArgument

$stub->method('insert')->willReturn(array('success'=>true,'data'=>$this->returnArgument(0)));

The only way I've been able to get the original argument is to return only the argument but then I don't have the array I need

$stub->method('insert')->will('data'=>$this->returnArgument(0));

Is there something small I'm doing wrong or do I need to try an implement a callback or something like that?

1 Answers
Related