I am writing a unit test for a method using PHPUnit. The method I am testing makes a call to the same method on the same object 3 times but with different sets of arguments. My question is similar to the questions asked here and here
The questions asked in the other posts have to do with mocking methods that only take one argument.
However, my method takes multiple arguments and I need something like this:
->with($this->logicalOr($this->equalTo($arg1, $arg2, arg3....argNb),
$this->equalTo($arg1b, $arg2b, arg3b....argNb),
$this->equalTo($arg1c, $arg2c, arg3c....argNc)
Argument #2 of PHPUnit_Framework_Constraint_IsEqual::__construct() must be a numeric
In my case the answer turned out to be quite simple:
$this->expects($this->at(0)) ->method('write') ->with(/* first set of params */); $this->expects($this->at(1)) ->method('write') ->with(/* second set of params */);
The key is to use
n being the Nth call of the method. I couldn't do anything with any of the
logicalOr() variants I tried.