Skip to content

Commit

Permalink
test: add test for storePreviousURL in case of non-HTML response
Browse files Browse the repository at this point in the history
  • Loading branch information
tearoom6 committed May 30, 2022
1 parent 6b3b7db commit b0ad044
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/system/CodeIgniterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,30 @@ public function testNotStoresPreviousURL()
$this->assertArrayNotHasKey('_ci_previous_url', $_SESSION);
}

public function testNotStoresPreviousURLByCheckingContentType()
{
$_SERVER['argv'] = ['index.php', 'image'];
$_SERVER['argc'] = 2;

$_SERVER['REQUEST_URI'] = '/image';

// Inject mock router.
$routes = Services::routes();
$routes->add('image', static function () {
$response = Services::response();

return $response->setContentType('image/jpeg', '');
});
$router = Services::router($routes, Services::request());
Services::injectMock('router', $router);

ob_start();
$this->codeigniter->useSafeOutput(true)->run();
ob_get_clean();

$this->assertArrayNotHasKey('_ci_previous_url', $_SESSION);
}

/**
* The method after all test, reset Servces:: config
* Can't use static::tearDownAfterClass. This will cause a buffer exception
Expand Down

0 comments on commit b0ad044

Please sign in to comment.