Пример #1
0
 /**
  * @param $method
  * @param $args
  * @return mixed
  */
 public function handle($method, $args)
 {
     $matchers = $this->mockingMonitor->getArgumentMatcherMonitor()->pullMatchers();
     $stackTrace = debug_backtrace();
     $invocation = new Invocation($this->mock, $method, $args, $matchers, $stackTrace);
     $verifcation = $this->mockingMonitor->currentVerification($this->mock);
     if ($verifcation != null) {
         $verifcation->getType()->verify($invocation, $this->invocationContainer);
         return null;
     }
     $this->invocationContainer->reportInvocataion($invocation, $matchers);
     $stub = new Stub($invocation);
     $this->mockingMonitor->reportStubbing(new OngoingStubbing($this->invocationContainer, $stub, $invocation));
     $stubbedInvocation = $this->invocationContainer->findAnswerFor($invocation);
     if ($stubbedInvocation == null) {
         return $this->options->getDefaultAnswer()->answer($invocation);
     } else {
         $this->mockingMonitor->reset();
         return $stubbedInvocation->answer($invocation);
     }
 }