Hi.
I’m just wondering the best way to be able to mock Aerospike functions for testing within my services. As an example, I can easily create a mockAerospike()
service which I can inject into my service, but when running the mock methods and telling it to return something it’s running into issues.
This is an example of using the mock Aerospike functionality:
// Declare the mock:
$this->mockAerospike = $this->getMockBuilder('Aerospike')
->disableOriginalConstructor()
->setMethods(['isConnected', 'get', 'put', 'exists'])
->getMock();
// Use it in a function:
$this->mockAerospike->expects($this->once())
->method('get')
->with($key, $record, null, $options)
->willReturn(Aerospike::OK);
This is all firing fine, but how do I effectively return some data from this get
function in order to be able to run the tests in my application?