Ejemplo n.º 1
0
 /**
  * Test event emitted when request transaction has ended.
  */
 public function testEndEvent()
 {
     $request = new Request('GET', '/');
     $response = new Response(200);
     $transaction = new Transaction(new Client(), $request);
     $transaction->response = $response;
     $transaction->transferInfo = ['total_time' => 10, 'connect_time' => 1];
     $event = new EndEvent($transaction);
     $stopwath = new Stopwatch(new \SplObjectStorage());
     $stopwath->onEnd($event);
     $expectedResult = ['total' => 10, 'connection' => 1];
     $storage = $stopwath->getStorage();
     $this->assertInstanceOf('SplObjectStorage', $storage);
     $this->assertSame($expectedResult, $storage->offsetGet($response));
 }
Ejemplo n.º 2
0
 /**
  * Construct the data collector.
  *
  * @param History $history History subscriber.
  * @param Stopwatch $stopwatch Stopwatch subscriber.
  */
 public function __construct(History $history, Stopwatch $stopwatch)
 {
     $this->profiler = $history;
     $this->storage = $stopwatch->getStorage();
 }