コード例 #1
0
 /**
  * @covers ::handleRequest
  */
 public function testHandlingRequestAndPreventingRenderingOfTheFoundRouteAndHandlingThat()
 {
     $this->application->addTestModule(new SplotResponseTestModule());
     $this->application->getContainer()->get('event_manager')->subscribe(DidFindRouteForRequest::getName(), function ($ev) {
         return false;
     });
     $didNotFoundRouteForRequestCalled = false;
     $handledResponse = new Response('Handled 404');
     $this->application->getContainer()->get('event_manager')->subscribe(DidNotFindRouteForRequest::getName(), function ($ev) use($handledResponse, &$didNotFoundRouteForRequestCalled) {
         $didNotFoundRouteForRequestCalled = true;
         $ev->setResponse($handledResponse);
         return false;
     });
     $response = $this->application->handleRequest(Request::create('/'));
     $this->assertTrue($didNotFoundRouteForRequestCalled);
     $this->assertSame($response, $handledResponse);
 }
コード例 #2
0
ファイル: EventsTest.php プロジェクト: splot/framework
 /**
  * @covers \Splot\Framework\Events\DidNotFindRouteForRequest::__construct
  * @covers \Splot\Framework\Events\DidNotFindRouteForRequest::getRequest
  * @covers \Splot\Framework\Events\DidNotFindRouteForRequest::isHandled
  * @covers \Splot\Framework\Events\DidNotFindRouteForRequest::setResponse
  * @covers \Splot\Framework\Events\DidNotFindRouteForRequest::getResponse
  */
 public function testDidNotFindRouteForRequest()
 {
     $request = Request::create('/test/');
     $event = new Events\DidNotFindRouteForRequest($request);
     $this->assertSame($request, $event->getRequest());
     $this->assertFalse($event->isHandled());
     $response = new Response('some response');
     $event->setResponse($response);
     $this->assertSame($response, $event->getResponse());
     $this->assertTrue($event->isHandled());
 }