public function testCountExceptionsByType()
 {
     $e = new \Exception();
     $this->profile->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0')))->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0'))->fail($e))->add(Profile\Interaction::call(new Location('foo'), new Request('foo', '0')))->add(Profile\Interaction::call(new Location('foo'), new Request('foo', '0'))->fail($e))->add(Profile\Interaction::broadcast(new Request('foo', '0')))->add(Profile\Interaction::broadcast(new Request('foo', '0'))->fail($e))->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0')))->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0'))->fail($e))->add(Profile\Interaction::call(new Location('foo'), new Request('foo', '0')))->add(Profile\Interaction::call(new Location('foo'), new Request('foo', '0'))->fail($e))->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0')))->add(Profile\Interaction::publish(new Location('foo'), new Request('foo', '0'))->fail($e));
     $this->assertEquals(6, $this->profile->countExceptions());
     $this->assertEquals(3, $this->profile->countPublishExceptions());
     $this->assertEquals(2, $this->profile->countCallExceptions());
     $this->assertEquals(1, $this->profile->countBroadcastExceptions());
 }
 /**
  * @param LocationInterface $location
  * @param Request           $request
  *
  * @throws \Exception
  */
 public function publish(LocationInterface $location, Request $request)
 {
     $interaction = Interaction::publish($location, $request);
     $this->profile->add($interaction);
     $interaction->start();
     try {
         $this->driver->publish($location, $request);
     } catch (\Exception $exception) {
         $interaction->fail($exception);
         $interaction->stop();
         throw $exception;
     }
     $interaction->stop();
 }
 public function indexAction()
 {
     $this->profile->add(Profile\Interaction::broadcast(new Message\Request('qux', '1.0', []))->start()->stop(usleep(15000)))->add(Profile\Interaction::publish(new Location('foo'), new Message\Request('baz', '1.0', []))->start()->stop(usleep(10000)))->add(Profile\Interaction::call(new Location('bar'), new Message\Request('boom', '1.0', []))->start()->reply(new Message\Response('reply'))->stop(usleep(25000)))->add(Profile\Interaction::call(new Location('bar'), new Message\Request('bug', '1.0', []))->start()->fail(new \Exception('oops...'))->stop(usleep(25000)));
     return new Response('<html><body><h1>Test Web Profiler</h1><p>Check out this awesome toolbar below!</p></body></html>');
 }
 /**
  * Publish constructor should set type to publish.
  */
 public function testMakePublish()
 {
     $interaction = Interaction::publish(new Location('bar'), new Request('foo', '0'));
     $this->assertEquals(Interaction::TYPE_PUBLISH, $interaction->getType());
 }