Example #1
0
 private function addStub($name, $arguments, $collected = [])
 {
     $stub = new Stub($this->factory, $this->mockster, $this->class, $name, $arguments, $collected);
     $stub->setStubbed($this->defaultStubbing);
     $stub->enableReturnTypeChecking($this->checkReturnType);
     $this->stubs[$name][] = $stub;
     return $stub;
 }
Example #2
0
 /**
  * @param Stub $stub
  * @param Mockster $mockster
  * @param History $history
  */
 public function __construct(Stub $stub, Mockster $mockster, History $history)
 {
     $this->history = $history;
     $this->stub = $stub;
     $this->mockster = $mockster;
     $args = $this->printArguments($this->stub->arguments());
     $this->methodCall = $this->stub->className() . '::' . $this->stub->methodName() . "({$args})";
 }
Example #3
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);
 }
Example #4
0
 /**
  * @return array|Call[]
  */
 public function calls()
 {
     return array_filter($this->stub->has()->calls(), function (Call $call) {
         foreach ($this->arguments as $i => $argument) {
             if (!$argument->accepts(new ExactArgument($call->argument($i)))) {
                 return false;
             }
         }
         return true;
     });
 }