Skip to content

Commit 8522e99

Browse files
committed
test: extract createSiteURIFactory()
1 parent 9937a03 commit 8522e99

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tests/system/HTTP/SiteURIFactoryTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ protected function setUp(): void
3131
$_GET = $_SERVER = [];
3232
}
3333

34+
private function createSiteURIFactory(?App $config = null, ?Superglobals $superglobals = null): SiteURIFactory
35+
{
36+
$config ??= new App();
37+
$superglobals ??= new Superglobals();
38+
39+
return new SiteURIFactory($superglobals, $config);
40+
}
41+
3442
public function testCreateFromGlobals()
3543
{
3644
// http://localhost:8080/index.php/woot?code=good#pos
@@ -42,8 +50,7 @@ public function testCreateFromGlobals()
4250

4351
$_GET['code'] = 'good';
4452

45-
$superglobals = new Superglobals();
46-
$factory = new SiteURIFactory($superglobals, new App());
53+
$factory = $this->createSiteURIFactory();
4754

4855
$uri = $factory->createFromGlobals();
4956

@@ -68,8 +75,7 @@ public function testCreateFromGlobalsAllowedHost()
6875
$config->baseURL = 'http://example.jp/';
6976
$config->allowedHostnames = ['users.example.jp'];
7077

71-
$superglobals = new Superglobals();
72-
$factory = new SiteURIFactory($superglobals, $config);
78+
$factory = $this->createSiteURIFactory($config);
7379

7480
$uri = $factory->createFromGlobals();
7581

@@ -81,8 +87,7 @@ public function testCreateFromGlobalsAllowedHost()
8187

8288
public function testCreateFromString()
8389
{
84-
$superglobals = new Superglobals();
85-
$factory = new SiteURIFactory($superglobals, new App());
90+
$factory = $this->createSiteURIFactory();
8691

8792
$uriString = 'http://invalid.example.jp/foo/bar?page=3';
8893
$uri = $factory->createFromString($uriString);

0 commit comments

Comments
 (0)