I was wondering if there was a way to be able to return results when mocking
Aerospike client functions?
given this piece of code:
// Get the data with optional bins: $status = $this->getAerospike()->get($key, $record, $binArray, $options);
I can mock and test with the following:
$this->mockAerospike->expects($this->once()) ->method('isConnected') ->willReturn(true); $this->mockAerospike->expects($this->once()) ->method('get') ->with($key, $record, null, $options) ->willReturn(Aerospike::OK);
As you can see, I can mock the connection so it thinks it’s connected and I can also mock the
get function, but in order for the application to function it checks that
$status === Aerospike::OK from the request (to indicate that everything worked, the record exists and nothing failed) but what I can’t seem to do is populate the
$record variable in order for the rest of the function to continue.
Any ideas how I may be able to do this in a testing environment? I’m guessing this must have been done before / talked about?