Exemple #1
0
 public function testSpyTracksCallOrderAcrossObjects()
 {
     $spy = Doubles::fromClass('\\SomeClass');
     $otherSpy = Doubles::fromClass('\\SomeOtherClass');
     $anotherSpy = Doubles::fromClass('\\SomeOtherClass');
     CallCounter::shareNew($spy, $otherSpy, $anotherSpy);
     $spy->method();
     $anotherSpy->anotherMethod();
     $otherSpy->otherMethod();
     $this->assertSame(1, $spy->spy('method')->sharedCallOrder(0));
     $this->assertSame(3, $otherSpy->spy('otherMethod')->sharedCallOrder(0));
     $this->assertSame(2, $anotherSpy->spy('anotherMethod')->sharedCallOrder(0));
 }
Exemple #2
0
 /**
  * Log a call to the subject method
  *
  * @arg array $args
  * @arg int $callOrder
  * @arg CallCounter $counter
  */
 public function log(array $args, $callOrder, CallCounter $counter = null)
 {
     $this->callCount++;
     $call = new \stdClass();
     $call->args = $args;
     $call->callOrder = $callOrder;
     if ($counter !== null) {
         $counter->tick();
         $call->sharedCallOrder = $counter->current();
     }
     $this->calls[] = $call;
 }