megaman's avatar

Partial mock problem

I am using the following code to make a partial mock.

$mock = $this->partialMock(Service::class, function (MockInterface $mock) { $mock->shouldReceive('process')->with('some string'); });

If the value received by process() is 'some string' then the mocked version of the process function runs and the expectation passes. As it should

However if a string other than 'some string' is passed to process() then the real version of the process function runs.

This is not what I want. I want a partial mock that mocks the process function regardless of what argument it receives and passes if it receives the expected value and fails if it receives any other value.

I cant use andRecieveAnyValue() function ( or whatever it is ) because this will always mock process() will never result in a fail if the wrong string is recieved.

0 likes
0 replies

Please or to participate in this conversation.