Skip to content

Commit 468b8b5

Browse files
committed
test: fix incorrect REQUEST_URI
The public is a folder, so should be end with `/`.
1 parent fc0a1b8 commit 468b8b5

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

tests/system/Helpers/URLHelper/CurrentUrlTest.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ protected function tearDown(): void
6161

6262
public function testCurrentURLReturnsBasicURL(): void
6363
{
64-
$_SERVER['REQUEST_URI'] = '/public';
64+
$_SERVER['REQUEST_URI'] = '/public/';
6565
$_SERVER['SCRIPT_NAME'] = '/public/index.php';
6666

67-
$this->config->baseURL = 'http://example.com/public';
67+
$this->config->baseURL = 'http://example.com/public/';
6868

6969
$this->createRequest($this->config);
7070

@@ -74,10 +74,10 @@ public function testCurrentURLReturnsBasicURL(): void
7474
public function testCurrentURLReturnsAllowedHostname(): void
7575
{
7676
$_SERVER['HTTP_HOST'] = 'www.example.jp';
77-
$_SERVER['REQUEST_URI'] = '/public';
77+
$_SERVER['REQUEST_URI'] = '/public/';
7878
$_SERVER['SCRIPT_NAME'] = '/public/index.php';
7979

80-
$this->config->baseURL = 'http://example.com/public';
80+
$this->config->baseURL = 'http://example.com/public/';
8181
$this->config->allowedHostnames = ['www.example.jp'];
8282

8383
$this->createRequest($this->config);
@@ -105,10 +105,10 @@ private function createRequest(?App $config = null, $body = null, ?string $path
105105
public function testCurrentURLReturnsBaseURLIfNotAllowedHostname(): void
106106
{
107107
$_SERVER['HTTP_HOST'] = 'invalid.example.org';
108-
$_SERVER['REQUEST_URI'] = '/public';
108+
$_SERVER['REQUEST_URI'] = '/public/';
109109
$_SERVER['SCRIPT_NAME'] = '/public/index.php';
110110

111-
$this->config->baseURL = 'http://example.com/public';
111+
$this->config->baseURL = 'http://example.com/public/';
112112
$this->config->allowedHostnames = ['www.example.jp'];
113113

114114
$this->createRequest($this->config);
@@ -118,8 +118,7 @@ public function testCurrentURLReturnsBaseURLIfNotAllowedHostname(): void
118118

119119
public function testCurrentURLReturnsObject(): void
120120
{
121-
// Since we're on a CLI, we must provide our own URI
122-
$this->config->baseURL = 'http://example.com/public';
121+
$this->config->baseURL = 'http://example.com/public/';
123122

124123
$this->createRequest($this->config);
125124

@@ -132,7 +131,7 @@ public function testCurrentURLReturnsObject(): void
132131
public function testCurrentURLEquivalence(): void
133132
{
134133
$_SERVER['HTTP_HOST'] = 'example.com';
135-
$_SERVER['REQUEST_URI'] = '/public';
134+
$_SERVER['REQUEST_URI'] = '/public/';
136135
$_SERVER['SCRIPT_NAME'] = '/index.php';
137136

138137
$this->config->indexPage = '';
@@ -148,8 +147,7 @@ public function testCurrentURLInSubfolder(): void
148147
$_SERVER['REQUEST_URI'] = '/foo/public/bar?baz=quip';
149148
$_SERVER['SCRIPT_NAME'] = '/foo/public/index.php';
150149

151-
// Since we're on a CLI, we must provide our own URI
152-
$this->config->baseURL = 'http://example.com/foo/public';
150+
$this->config->baseURL = 'http://example.com/foo/public/';
153151

154152
$this->createRequest($this->config);
155153

@@ -169,7 +167,7 @@ public function testCurrentURLWithPortInSubfolder(): void
169167
$_SERVER['REQUEST_URI'] = '/foo/public/bar?baz=quip';
170168
$_SERVER['SCRIPT_NAME'] = '/foo/public/index.php';
171169

172-
$this->config->baseURL = 'http://example.com:8080/foo/public';
170+
$this->config->baseURL = 'http://example.com:8080/foo/public/';
173171

174172
$this->createRequest($this->config);
175173

@@ -210,7 +208,7 @@ public function testUriStringNoTrailingSlash(): void
210208
$_SERVER['HTTP_HOST'] = 'example.com';
211209
$_SERVER['REQUEST_URI'] = '/assets/image.jpg';
212210

213-
$this->config->baseURL = 'http://example.com';
211+
$this->config->baseURL = 'http://example.com/';
214212
$this->config->indexPage = '';
215213

216214
$this->createRequest($this->config);

0 commit comments

Comments
 (0)