Skip to content

Commit a8c17cd

Browse files
committed
Fix tests
1 parent f934428 commit a8c17cd

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

system/CodeIgniter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
400400
$filters->enableFilter($routeFilter, 'after');
401401
}
402402

403-
$uri = $this->request instanceof CLIRequest ? $this->request->getPath() : $this->request->getUri()->getPath();
403+
$uri = $this->determinePath();
404404

405405
// Never run filters when running through Spark cli
406406
if (! defined('SPARKED'))
@@ -846,8 +846,7 @@ protected function determinePath()
846846
return $this->path;
847847
}
848848

849-
// @phpstan-ignore-next-line
850-
return (is_cli() && ! (ENVIRONMENT === 'testing')) ? $this->request->getPath() : $this->request->uri->getPath();
849+
return method_exists($this->request, 'getPath') ? $this->request->getPath() : $this->request->getUri()->getPath();
851850
}
852851

853852
//--------------------------------------------------------------------

tests/system/CodeIgniterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function testRunForceSecure()
283283
$codeigniter->useSafeOutput(true)->run();
284284
$output = ob_get_clean();
285285

286-
$this->assertEquals('https://example.com/', $response->header('Location')->getValue());
286+
$this->assertEquals('https://example.com/index.php', $response->header('Location')->getValue());
287287
}
288288

289289
public function testRunRedirectionWithNamed()

tests/system/CommonFunctionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function testForceHttpsNullRequestAndResponse()
426426

427427
force_https();
428428

429-
$this->assertEquals('https://example.com/', Services::response()->header('Location')->getValue());
429+
$this->assertEquals('https://example.com/index.php', Services::response()->header('Location')->getValue());
430430
}
431431

432432
/**

tests/system/Helpers/URLHelperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ public function testCurrentURLInSubfolder()
426426
$request = Services::request($this->config);
427427
Services::injectMock('request', $request);
428428

429-
$this->assertEquals('http://example.com/foo/public/bar', current_url());
430-
$this->assertEquals('http://example.com/foo/public/bar?baz=quip', (string) current_url(true));
429+
$this->assertEquals('http://example.com/foo/public/index.php/bar', current_url());
430+
$this->assertEquals('http://example.com/foo/public/index.php/bar?baz=quip', (string) current_url(true));
431431

432432
$uri = current_url(true);
433433
$this->assertEquals(['bar'], $uri->getSegments());
@@ -450,8 +450,8 @@ public function testCurrentURLWithPortInSubfolder()
450450
$request = Services::request($this->config);
451451
Services::injectMock('request', $request);
452452

453-
$this->assertEquals('http://example.com:8080/foo/public/bar', current_url());
454-
$this->assertEquals('http://example.com:8080/foo/public/bar?baz=quip', (string) current_url(true));
453+
$this->assertEquals('http://example.com:8080/foo/public/index.php/bar', current_url());
454+
$this->assertEquals('http://example.com:8080/foo/public/index.php/bar?baz=quip', (string) current_url(true));
455455

456456
$uri = current_url(true);
457457
$this->assertEquals(['bar'], $uri->getSegments());

0 commit comments

Comments
 (0)