예제 #1
0
파일: Stubs.php 프로젝트: rtens/mockster
 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;
 }
예제 #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})";
 }
예제 #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);
 }
예제 #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;
     });
 }