Skip to content

Commit

Permalink
test: extract setUp()
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 15, 2023
1 parent a9a81e8 commit 5af1578
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions tests/system/HTTP/SiteURIFactoryDetectRoutePathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
*/
final class SiteURIFactoryDetectRoutePathTest extends CIUnitTestCase
{
protected function setUp(): void
{
parent::setUp();

$_GET = $_SERVER = [];
}

private function createSiteURIFactory(array $server, ?App $appConfig = null): SiteURIFactory
{
$appConfig ??= new App();
Expand All @@ -32,8 +39,6 @@ private function createSiteURIFactory(array $server, ?App $appConfig = null): Si

public function testDefault()
{
$_GET = $_SERVER = [];

// /index.php/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php/woot';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -46,8 +51,6 @@ public function testDefault()

public function testDefaultEmpty()
{
$_GET = $_SERVER = [];

// /
$_SERVER['REQUEST_URI'] = '/';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -60,8 +63,6 @@ public function testDefaultEmpty()

public function testRequestURI()
{
$_GET = $_SERVER = [];

// /index.php/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php/woot';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -74,8 +75,6 @@ public function testRequestURI()

public function testRequestURINested()
{
$_GET = $_SERVER = [];

// I'm not sure but this is a case of Apache config making such SERVER
// values?
// The current implementation doesn't use the value of the URI object.
Expand All @@ -96,8 +95,6 @@ public function testRequestURINested()

public function testRequestURISubfolder()
{
$_GET = $_SERVER = [];

// /ci/index.php/popcorn/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/ci/index.php/popcorn/woot';
$_SERVER['SCRIPT_NAME'] = '/ci/index.php';
Expand All @@ -110,8 +107,6 @@ public function testRequestURISubfolder()

public function testRequestURINoIndex()
{
$_GET = $_SERVER = [];

// /sub/example
$_SERVER['REQUEST_URI'] = '/sub/example';
$_SERVER['SCRIPT_NAME'] = '/sub/index.php';
Expand All @@ -124,8 +119,6 @@ public function testRequestURINoIndex()

public function testRequestURINginx()
{
$_GET = $_SERVER = [];

// /ci/index.php/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php/woot?code=good';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -138,8 +131,6 @@ public function testRequestURINginx()

public function testRequestURINginxRedirecting()
{
$_GET = $_SERVER = [];

// /?/ci/index.php/woot
$_SERVER['REQUEST_URI'] = '/?/ci/woot';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -152,8 +143,6 @@ public function testRequestURINginxRedirecting()

public function testRequestURISuppressed()
{
$_GET = $_SERVER = [];

// /woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/woot';
$_SERVER['SCRIPT_NAME'] = '/';
Expand All @@ -166,8 +155,6 @@ public function testRequestURISuppressed()

public function testQueryString()
{
$_GET = $_SERVER = [];

// /index.php?/ci/woot
$_SERVER['REQUEST_URI'] = '/index.php?/ci/woot';
$_SERVER['QUERY_STRING'] = '/ci/woot';
Expand All @@ -183,8 +170,6 @@ public function testQueryString()

public function testQueryStringWithQueryString()
{
$_GET = $_SERVER = [];

// /index.php?/ci/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php?/ci/woot?code=good';
$_SERVER['QUERY_STRING'] = '/ci/woot?code=good';
Expand All @@ -202,8 +187,6 @@ public function testQueryStringWithQueryString()

public function testQueryStringEmpty()
{
$_GET = $_SERVER = [];

// /index.php?
$_SERVER['REQUEST_URI'] = '/index.php?';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -216,8 +199,6 @@ public function testQueryStringEmpty()

public function testPathInfoUnset()
{
$_GET = $_SERVER = [];

// /index.php/woot?code=good#pos
$_SERVER['REQUEST_URI'] = '/index.php/woot';
$_SERVER['SCRIPT_NAME'] = '/index.php';
Expand All @@ -230,8 +211,6 @@ public function testPathInfoUnset()

public function testPathInfoSubfolder()
{
$_GET = $_SERVER = [];

$appConfig = new App();
$appConfig->baseURL = 'http://localhost:8888/ci431/public/';

Expand Down

0 comments on commit 5af1578

Please sign in to comment.