コード例 #1
0
ファイル: RequestTest.php プロジェクト: fuelphp/foundation
 public function test404Request()
 {
     $app = Application::init(['components' => ['Basic']]);
     $request = new HttpRequest([], [], '/should/not/exist');
     $response = $app->performRequest($request);
     $this->assertEquals(404, $response->getStatusCode());
 }
コード例 #2
0
 public function testMakeRequest()
 {
     $requestStartCalled = false;
     $requestStartApplication = null;
     $requestEndCalled = false;
     $requestEndApplication = null;
     $app = Application::init(['components' => ['Basic'], 'events' => [['name' => 'fuel.request.started', 'listener' => function (RequestStarted $requestStarted) use(&$requestStartCalled, &$requestStartApplication) {
         $requestStartCalled = true;
         $requestStartApplication = $requestStarted->getApplication();
     }], ['name' => 'fuel.request.finished', 'listener' => function (RequestFinished $requestFinished) use(&$requestEndCalled, &$requestEndApplication) {
         $requestEndCalled = true;
         $requestEndApplication = $requestFinished->getApplication();
     }]]]);
     $request = new HttpRequest([], [], '/testroute');
     $response = $app->performRequest($request);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('found me', (string) $response->getBody());
     $this->assertTrue($requestStartCalled);
     $this->assertSame($app, $requestStartApplication);
     $this->assertTrue($requestEndCalled);
     $this->assertSame($app, $requestEndApplication);
 }
コード例 #3
0
 public function testConstructResponse()
 {
     $this->assertInstanceOf('Fuel\\Foundation\\Response\\Cli', Application::init([])->getDependencyContainer()->get('fuel.application.response'));
 }