/** * Executes the matcher on a given argument value. * * Sets the $argument to the value passed in the constructor * * @param mixed $argument * @throws Phake_Exception_MethodMatcherException */ protected function matches(&$argument) { $args = array(); $args[] =& $argument; if ($this->matcher !== null) { try { $this->matcher->doArgumentsMatch($args); } catch (Phake_Exception_MethodMatcherException $e) { throw new Phake_Exception_MethodMatcherException(trim("Failed in Phake::setReference()->when()\n" . $e->getMessage()), $e); } $this->matcher->doArgumentsMatch($args); } $argument = $this->value; }
/** * Determines whether or not given arguments match the argument matchers configured in the object. * * Throws an exception with a description if the arguments do not match. * * @param array $args * @return bool * @throws Phake_Exception_MethodMatcherException */ private function doArgumentsMatch(array &$args) { if ($this->argumentMatcherChain !== null) { try { $this->argumentMatcherChain->doArgumentsMatch($args); } catch (Phake_Exception_MethodMatcherException $e) { $position = $e->getArgumentPosition() + 1; throw new Phake_Exception_MethodMatcherException(trim("Argument #{$position} failed test\n" . $e->getMessage()), $e); } } elseif (count($args) != 0) { throw new Phake_Exception_MethodMatcherException("No matchers were given to Phake::when(), but arguments were received by this method."); } }
public function __toString() { return sprintf('<captured parameter%s>', isset($this->matcher) ? " that is {$this->matcher->__toString()}" : ''); }
public function setNextMatcher(Phake_Matchers_IChainableArgumentMatcher $nextMatcher) { $nextMatcher->assertPreviousMatcher($this); $this->nextMatcher = $nextMatcher; }