An alternative to using argument capturing is creating custom matchers. All parameter matchers implement the interface Phake_Matchers_IArgumentMatcher. You can create custom implementations of this interface. This is especially useful if you find yourself using a similar capturing pattern over and over again. If I were to rewriting the test above using a customer argument matcher it would look something like this.
Example 5.10. Custom Argument Matcher
<?php class FiftyTwoCardDeckMatcher implements Phake_Matchers_IArgumentMatcher { public function matches($argument) { return ($argument instanceof CardCollection && $argument->getNumberOfCards() == 52); } public function __toString() { return '<object:CardCollection with 52 cards>'; } } class MyBestPokerGameTest extends PHPUnit_Framework_TestCase { public function testDealCards() { $dealer = Phake::mock('MyPokerDealer'); $players = Phake::mock('PlayerCollection'); $cardGame = new MyPokerGame($dealer, $players); Phake::verify($dealer)->deal(new 52CardDeckMatcher(), $players); } } ?>