/** * 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."); } }
/** * Executes the matcher on a given argument value. Returns TRUE on a match, FALSE otherwise. * * Will bind the argument to the variable passed to 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::capture()->when()\n" . $e->getMessage()), $e); } } $this->boundVariable = $argument; $this->allCapturedValues[] = $argument; }