Skip to content

Commit 20d43da

Browse files
committed
Refactor SiteURIFactory to use injected App config
Replaces usage of global config(App::class) with the injected $appConfig property in SiteURIFactory. Updates related test to pass App config instance directly, improving test isolation and code clarity.
1 parent ff0c9b3 commit 20d43da

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

system/HTTP/SiteURIFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function detectRoutePath(string $protocol = ''): string
111111
*/
112112
private function parseRequestURI(): string
113113
{
114-
$appConfig = config(App::class);
114+
$appConfig = $this->appConfig;
115115
$baseUrl = $appConfig->baseURL;
116116
$indexPage = $appConfig->indexPage;
117117
$baseUri = false;

tests/system/HTTP/SiteURIFactoryTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,17 @@ public function testCreateFromStringWithIndexPageSubDirCombinations(
180180
$standardUrl = 'http://localhost:8080';
181181
$standardScriptName = '/public/index.php';
182182

183-
$route = 'controller/method';
184-
config(App::class)->baseURL = $standardUrl . $subDir;
185-
config(App::class)->indexPage = $indexPage;
183+
$route = 'controller/method';
184+
$appConfig = new App();
185+
$appConfig->baseURL = $standardUrl . $subDir;
186+
$appConfig->indexPage = $indexPage;
186187

187188
$_SERVER['PATH_INFO'] = '/' . $route;
188189
$_SERVER['REQUEST_URI'] = $subDir . '/' . $indexPage . $_SERVER['PATH_INFO'];
189190
$_SERVER['SCRIPT_NAME'] = $subDir . $standardScriptName;
190191
$_SERVER['HTTP_HOST'] = $standardUrl;
191192

192-
$factory = $this->createSiteURIFactory();
193+
$factory = $this->createSiteURIFactory($appConfig);
193194
$detectedRoutePath = $factory->detectRoutePath();
194195
$this->assertSame($route, $detectedRoutePath);
195196
}

0 commit comments

Comments
 (0)