Ejemplo n.º 1
0
 public function fakeMethodsAndRegisterCalls($class, $declaredClass, $method, $params, $static)
 {
     //        $method = $invocation->getMethod();
     //        $obj = $invocation->getThis();
     $result = __AM_CONTINUE__;
     if (in_array($method, $this->methodMap)) {
         $invocation = new \AspectMock\Intercept\MethodInvocation();
         $invocation->setThis($class);
         $invocation->setMethod($method);
         $invocation->setArguments($params);
         $invocation->isStatic($static);
         $invocation->setDeclaredClass($declaredClass);
         $result = $this->invokeFakedMethods($invocation);
     }
     // Record actual method called, not faked method.
     if (in_array($method, $this->dynamicMethods)) {
         $method = array_shift($params);
         $params = array_shift($params);
     }
     if (!$static) {
         if (isset($this->objectMap[spl_object_hash($class)])) {
             Registry::registerInstanceCall($class, $method, $params);
         }
         $class = get_class($class);
     }
     if (isset($this->classMap[$class])) {
         Registry::registerClassCall($class, $method, $params);
     }
     return $result;
 }
Ejemplo n.º 2
0
 protected function stubMagicMethod(MethodInvocation $invocation, $params)
 {
     $args = $invocation->getArguments();
     $name = array_shift($args);
     $replacedMethod = $params[$name];
     $replacedMethod = $this->turnToClosure($replacedMethod);
     if ($invocation->isStatic()) {
         \Closure::bind($replacedMethod, null, $invocation->getThis());
     } else {
         $replacedMethod = $replacedMethod->bindTo($invocation->getThis(), get_class($invocation->getThis()));
     }
     return call_user_func_array($replacedMethod, $args);
 }