Skip to content

Commit 034e0c4

Browse files
authored
Merge pull request #3973 from codeigniter4/redundant-http-keys
Deprecate redundant HTTP keys
2 parents 5ad1235 + 92bfe95 commit 034e0c4

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

system/HTTP/Exceptions/HTTPException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,6 @@ public static function forMoveFailed(string $source, string $target, string $err
241241
*/
242242
public static function forInvalidSameSiteSetting(string $samesite)
243243
{
244-
return new static(lang('HTTP.invalidSameSiteSetting', [$samesite]));
244+
return new static(lang('Security.invalidSameSiteSetting', [$samesite]));
245245
}
246246
}

system/Language/en/HTTP.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
'methodNotFound' => 'Controller method is not found: {0}',
5555

5656
// CSRF
57+
// @deprecated use `Security.disallowedAction`
5758
'disallowedAction' => 'The action you requested is not allowed.',
5859

5960
// Uploaded file moving
@@ -72,5 +73,6 @@
7273
'uploadErrUnknown' => 'The file "%s" was not uploaded due to an unknown error.',
7374

7475
// SameSite setting
76+
// @deprecated use `Security.invalidSameSiteSetting`
7577
'invalidSameSiteSetting' => 'The SameSite setting must be None, Lax, Strict, or a blank string. Given: {0}',
7678
];

tests/system/HTTP/ResponseCookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public function testCookieInvalidSameSite()
308308
$response = new Response($config);
309309

310310
$this->expectException(HTTPException::class);
311-
$this->expectExceptionMessage(lang('HTTP.invalidSameSiteSetting', ['Invalid']));
311+
$this->expectExceptionMessage(lang('Security.invalidSameSiteSetting', ['Invalid']));
312312

313313
$response->setCookie([
314314
'name' => 'bar',

tests/system/HTTP/ResponseTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace CodeIgniter\HTTP;
44

5-
use CodeIgniter\Config\Config;
5+
use CodeIgniter\Config\Factories;
66
use CodeIgniter\HTTP\Exceptions\HTTPException;
7+
use CodeIgniter\Test\CIUnitTestCase;
78
use CodeIgniter\Test\Mock\MockResponse;
89
use Config\App;
910
use Config\Services;
1011
use DateTime;
1112
use DateTimeZone;
1213

13-
class ResponseTest extends \CodeIgniter\Test\CIUnitTestCase
14+
class ResponseTest extends CIUnitTestCase
1415
{
15-
1616
protected $server;
1717

1818
protected function setUp(): void
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
public function tearDown(): void
2525
{
2626
$_SERVER = $this->server;
27-
Config::reset();
27+
Factories::reset('config');
2828
}
2929

3030
public function testCanSetStatusCode()
@@ -65,7 +65,7 @@ public function testSetStatusCodeSetsReason()
6565

6666
$response->setStatusCode(200);
6767

68-
$this->assertEquals('OK', $response->getReason());
68+
$this->assertEquals('OK', $response->getReasonPhrase());
6969
}
7070

7171
//--------------------------------------------------------------------
@@ -76,7 +76,7 @@ public function testCanSetCustomReasonCode()
7676

7777
$response->setStatusCode(200, 'Not the mama');
7878

79-
$this->assertEquals('Not the mama', $response->getReason());
79+
$this->assertEquals('Not the mama', $response->getReasonPhrase());
8080
}
8181

8282
//--------------------------------------------------------------------
@@ -120,7 +120,7 @@ public function testSetStatusCodeInterpretsReason()
120120

121121
$response->setStatusCode(300);
122122

123-
$this->assertEquals('Multiple Choices', $response->getReason());
123+
$this->assertEquals('Multiple Choices', $response->getReasonPhrase());
124124
}
125125

126126
//--------------------------------------------------------------------
@@ -131,7 +131,7 @@ public function testSetStatusCodeSavesCustomReason()
131131

132132
$response->setStatusCode(300, 'My Little Pony');
133133

134-
$this->assertEquals('My Little Pony', $response->getReason());
134+
$this->assertEquals('My Little Pony', $response->getReasonPhrase());
135135
}
136136

137137
//--------------------------------------------------------------------
@@ -140,7 +140,7 @@ public function testGetReasonDefaultsToOK()
140140
{
141141
$response = new Response(new App());
142142

143-
$this->assertEquals('OK', $response->getReason());
143+
$this->assertEquals('OK', $response->getReasonPhrase());
144144
}
145145

146146
//--------------------------------------------------------------------
@@ -166,7 +166,7 @@ public function testSetLink()
166166
// Ensure our URL is not getting overridden
167167
$config = new App();
168168
$config->baseURL = 'http://example.com/test/';
169-
Config::injectMock('App', $config);
169+
Factories::injectMock('config', 'App', $config);
170170

171171
$response = new Response($config);
172172
$pager = \Config\Services::pager();
@@ -552,7 +552,7 @@ public function testInvalidSameSiteCookie()
552552
$config->cookieSameSite = 'Invalid';
553553

554554
$this->expectException(HTTPException::class);
555-
$this->expectExceptionMessage(lang('HTTP.invalidSameSiteSetting', ['Invalid']));
555+
$this->expectExceptionMessage(lang('Security.invalidSameSiteSetting', ['Invalid']));
556556
new Response($config);
557557
}
558558
}

tests/system/Helpers/CookieHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testSameSiteInvalid()
141141
];
142142

143143
$this->expectException(HTTPException::class);
144-
$this->expectExceptionMessage(lang('HTTP.invalidSameSiteSetting', ['Invalid']));
144+
$this->expectExceptionMessage(lang('Security.invalidSameSiteSetting', ['Invalid']));
145145

146146
set_cookie($cookieAttr);
147147
}

0 commit comments

Comments
 (0)