Ejemplo n.º 1
0
 private function addStub($name, $arguments, $collected = [])
 {
     $stub = new Stub($this->factory, $this->class, $name, $arguments, $collected);
     $stub->setStubbed($this->defaultStubbing);
     $stub->enableReturnTypeChecking($this->checkReturnType);
     $this->stubs[$name][] = $stub;
     return $stub;
 }
Ejemplo n.º 2
0
 /**
  * @param Stub $stub
  * @return string
  */
 public function printStub(Stub $stub)
 {
     $class = $stub->className();
     $method = $stub->methodName();
     $calls = $stub->has()->calls();
     if (!$calls) {
         return "No calls recorded for [{$class}::{$method}()]";
     }
     return "History of [{$class}::{$method}()]\n  " . $this->printCalls($method, $calls);
 }
Ejemplo n.º 3
0
 /**
  * @return array|Call[]
  */
 public function calls()
 {
     return array_filter($this->stub->has()->calls(), function (Call $call) {
         foreach ($this->arguments as $i => $argument) {
             $callArguments = $call->arguments();
             if (!array_key_exists($i, $callArguments) || !$argument->accepts(new ExactArgument($call->argument($i)))) {
                 return false;
             }
         }
         return true;
     });
 }