test: add test for storePreviousURL in case of non-HTML response

This commit is contained in:
Tomohiro Murota 2022-05-30 11:08:37 +09:00
parent fd19d90a83
commit 753f9e68ea
No known key found for this signature in database
GPG Key ID: C35C713D41EC66D7

View File

@ -424,6 +424,30 @@ final class CodeIgniterTest extends CIUnitTestCase
$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