Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed May 7, 2021
1 parent f934428 commit a8c17cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
$filters->enableFilter($routeFilter, 'after');
}

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

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

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

//--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/system/CodeIgniterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function testRunForceSecure()
$codeigniter->useSafeOutput(true)->run();
$output = ob_get_clean();

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

public function testRunRedirectionWithNamed()
Expand Down
2 changes: 1 addition & 1 deletion tests/system/CommonFunctionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ public function testForceHttpsNullRequestAndResponse()

force_https();

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

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/system/Helpers/URLHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ public function testCurrentURLInSubfolder()
$request = Services::request($this->config);
Services::injectMock('request', $request);

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

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

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

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

0 comments on commit a8c17cd

Please sign in to comment.