_arguments_match() public static method

Checks if the two argument sets (passed as arrays) match. Simple serialized check for now, to be replaced by something that can handle anyString etc matchers later
public static _arguments_match ( $mockclass, $method, $a, $b )
示例#1
0
 /**
  * Store the method and args we're stubbing
  */
 private function __phockito_setMethod($method, $args)
 {
     $instance = $this->instance;
     $this->method = $method;
     if (!isset(Phockito::$_responses[$instance])) {
         Phockito::$_responses[$instance] = array();
     }
     if (!isset(Phockito::$_responses[$instance][$method])) {
         Phockito::$_responses[$instance][$method] = array();
     }
     $this->i = count(Phockito::$_responses[$instance][$method]);
     foreach (Phockito::$_responses[$instance][$method] as $i => &$matcher) {
         if (Phockito::_arguments_match($this->class, $method, $matcher['args'], $args)) {
             $this->i = $i;
             break;
         }
     }
     Phockito::$_responses[$instance][$method][$this->i] = array('args' => $args, 'steps' => array());
 }
示例#2
0
 function __call($called, $args)
 {
     $count = 0;
     foreach (Phockito::$_call_list as $call) {
         if ($call['instance'] == $this->instance && $call['method'] == $called && Phockito::_arguments_match($this->class, $called, $args, $call['args'])) {
             $count++;
         }
     }
     if (preg_match('/([0-9]+)\\+/', $this->times, $match)) {
         if ($count >= (int) $match[1]) {
             return;
         }
     } else {
         if ($count == $this->times) {
             return;
         }
     }
     $message = "Failed asserting that method {$called} was called {$this->times} times - actually called {$count} times.\n";
     $message .= "Wanted call:\n";
     $message .= print_r($args, true);
     $message .= "Calls:\n";
     foreach (Phockito::$_call_list as $call) {
         if ($call['instance'] == $this->instance && $call['method'] == $called) {
             $message .= print_r($call['args'], true);
         }
     }
     $exceptionClass = self::$exception_class;
     throw new $exceptionClass($message);
 }