I saw in the Laravel docs that it's possible to set a test expectation like this:
Cache::shouldReceive('get')
->once()
->with('key')
->andReturn('value');
Then I saw in the PHPunit docs that flexible argument matching is possible like this: $this->stringContains('Something')
.
But when I edit my test to have this:
Log::shouldReceive('error')
->once();
->with($this->stringContains('Contact does not exist'));
...then I get the following error:
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_1_Illuminate_Log_Writer::error("Contact does not exist blah blah etc").
Either the method was unexpected or its arguments matched no expected argument list for this method
How can I accomplish my goal (with flexible argument matching within Log::shouldReceive
)?
P.S. I've also tried ->with(\PHPUnit\Framework\Assert::stringContains('Contact does not exist'))
.