title: PHPUnit test method is called multiple times with specific arguments in no specific order
body: <p>I have a question regarding testing some method invokes x times with specific arguments.</p>
  
  <p><strong>Situation:</strong></p>
  
  <p>I have a class Grid. It handles a two-dimensional array. It contains a method </p>
  
  <pre><code>public function setCell($x, $y, $value) : void
  </code></pre>
  
  <p>which sets value $value at coordinates $x and $y.</p>
  
  <p>Next I have a class GridShifter. It contains a method</p>
  
  <pre><code>public function shiftRow($grid : Grid, $rowNumber : int) : void
  </code></pre>
  
  <p>This method shifts all values at row number $rowNumber to the right. For example:</p>
  
  <pre><code>$grid = new Grid([[1, 2, 3]]);
  $gridShifter-&gt;shiftRow($grid, 1);
  // prints two dimensional array
  print_r($grid-&gt;printGrid());
  </code></pre>
  
  <p>Will result in</p>
  
  <pre><code>[[3, 1, 2]]
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>I want to test the shiftRow method of GridShifter without testing the setCell functionality of the Grid class by mocking the this method and checking how many times the method is called (for this example 3) and checking the arguments of the invokes.</p>
  
  <p>Solutions that didn't work for me:</p>
  
  <p>I've tried several solutions. $gridMock is a mock of the Grid class.</p>
  
  <p>1) withConsecutive or at($x)</p>
  
  <pre><code>$gridMock-&gt;expect($this-&gt;exactly(3))-&gt;method('setCell')-&gt;withConsecutive(
      [1, 1, 3],
      [1, 2, 2],
      [1, 3, 1]
  );
  </code></pre>
  
  <p>This passes my test, but this doesn't work for me because it also tests the order it's executed in. I'm not interested in the order they are invoked.</p>
  
  <p>2) returnValueMap</p>
  
  <pre><code>$gridMock-&gt;expect($this-&gt;exactly(3))-&gt;method('setCell')-&gt;will($this-returnValueMap([
      [1, 1, 3],
      [1, 2, 2],
      [1, 3, 1]
  ]);
  </code></pre>
  
  <p>This doesn't test my needs. In this case the tests will also pass when setCell is invoked three times with arguments 1, 1 and 3 without invoking the setCell with the other arguments</p>
  
  <p>3) withConsecutive with logicalOr</p>
  
  <pre><code>$gridMock-&gt;expect($this-&gt;exactly(3))-&gt;method('setCell')-&gt;withConsecutive(
      $this-&gt;logicalOr(
          [1, 1, 3],
          [1, 2, 2],
          [1, 3, 1]
      )
  );
  </code></pre>
  
  <p>This passes my tests too but has the same problem as solution 2. It doesn't test whether all three sets of arguments are called.</p>
  
  <p>Can somebody think of a solution that will test setCell is called three times in shiftCell with each time passing different specified arguments in any order?</p>
  
  <p>Above classes and examples are simplified. It describes my situation but it isn't my exact situation. All important details are in this question.</p>
  
  <p>Thanks in advance</p>