public function test404Request() { $app = Application::init(['components' => ['Basic']]); $request = new HttpRequest([], [], '/should/not/exist'); $response = $app->performRequest($request); $this->assertEquals(404, $response->getStatusCode()); }
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); }
public function testConstructResponse() { $this->assertInstanceOf('Fuel\\Foundation\\Response\\Cli', Application::init([])->getDependencyContainer()->get('fuel.application.response')); }