In the code below
$mockObject->expects($this->at(0)) ->method('search') ->with($searchConfig) ->will($this->returnValue([]));
This line will automatically make the statement that when the search method is called, it must contain the parameters $searchConfig . In this case, we must ensure that $searchConfig fully consistent, but sometimes it is difficult if it is an array or an object.
Is there any possible way for PHPUnit to call any particular method in order to claim that it contains arguments, passed in the form we want?
For example, I can create a close function to assert, as shown below, instead of the ->with() method
function ($config){ $this->assertFalse(isset($config['shouldnothere'])); $this->assertTrue($config['object']->isValidValue()); }
php unit-testing phpunit
scalopus
source share