public function testProcessResponseTriggerFinishEventIfTheSystemEventIsNotAtTheFinish()
 {
     $server = new Server();
     $events = $this->getMock(Events::CLASS);
     $strategy = new HtmlErrorStrategy();
     $strategy->setServer($server);
     $strategy->setEvents($events);
     $event = new SystemEvent();
     $response = new Response();
     $events->expects($this->once())->method('trigger')->with($this->callback(function ($systemEvent) use($event, $response) {
         $this->assertSame($systemEvent, $event);
         $this->assertSame($response, $systemEvent->getResult(SystemEvent::FINISH));
         return true;
     }));
     $strategy->processResponse($response, $event);
 }
 public function testHandleProductionErrorWithSpecifiedStatus()
 {
     $renderer = $this->getMock(ErrorRenderer::CLASS);
     $events = $this->getMock(Events::CLASS);
     $strategy = new HtmlErrorStrategy();
     $strategy->setRenderer($renderer);
     $strategy->setEvents($events);
     $event = new SystemEvent('Foo');
     $exception = new FakeException('Foo', 405);
     $content = 'Lorem ipsum dolor sit amet';
     $renderer->expects($this->once())->method('render')->with($this->identicalTo('error/production'))->will($this->returnValue($content));
     $events->expects($this->once())->method('trigger')->with($this->identicalTo($event));
     $strategy->handleProductionError($event, $exception);
     $response = $event->getResult(SystemEvent::FINISH);
     $this->assertInstanceOf(ResponseInterface::CLASS, $response);
     $this->assertSame($content, (string) $response->getBody());
     $this->assertSame('text/html', $response->getHeaderLine('Content-Type'));
     $this->assertSame(405, $response->getStatusCode());
 }