Skip to content

Commit 584bcd1

Browse files
committed
Fix test config type
1 parent 89d588f commit 584bcd1

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

system/HTTP/IncomingRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class IncomingRequest extends Request
124124
/**
125125
* Constructor
126126
*
127-
* @param object $config
127+
* @param App $config
128128
* @param URI $uri
129129
* @param string|null $body
130130
* @param UserAgent $userAgent

tests/system/API/ResponseTraitTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use CodeIgniter\Test\CIUnitTestCase;
99
use CodeIgniter\Test\Mock\MockIncomingRequest;
1010
use CodeIgniter\Test\Mock\MockResponse;
11+
use Config\App;
1112
use stdClass;
1213

1314
class ResponseTraitTest extends CIUnitTestCase
@@ -30,7 +31,8 @@ protected function setUp(): void
3031

3132
protected function makeController(array $userConfig = [], string $uri = 'http://example.com', array $userHeaders = [])
3233
{
33-
$config = [
34+
$config = new App();
35+
foreach ([
3436
'baseURL' => 'http://example.com/',
3537
'uriProtocol' => 'REQUEST_URI',
3638
'defaultLocale' => 'en',
@@ -44,9 +46,10 @@ protected function makeController(array $userConfig = [], string $uri = 'http://
4446
'cookieHTTPOnly' => false,
4547
'proxyIPs' => [],
4648
'cookieSameSite' => 'Lax',
47-
];
48-
49-
$config = array_merge($config, $userConfig);
49+
] as $key => $value)
50+
{
51+
$config->$key = $value;
52+
}
5053

5154
if (is_null($this->request))
5255
{
@@ -472,7 +475,8 @@ public function testXMLFormatter()
472475

473476
public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML()
474477
{
475-
$config = [
478+
$config = new App();
479+
foreach ([
476480
'baseURL' => 'http://example.com/',
477481
'uriProtocol' => 'REQUEST_URI',
478482
'defaultLocale' => 'en',
@@ -486,10 +490,13 @@ public function testFormatByRequestNegotiateIfFormatIsNotJsonOrXML()
486490
'cookieHTTPOnly' => false,
487491
'proxyIPs' => [],
488492
'cookieSameSite' => 'Lax',
489-
];
493+
] as $key => $value)
494+
{
495+
$config->$key = $value;
496+
}
490497

491-
$request = new MockIncomingRequest((object) $config, new URI($config['baseURL']), null, new UserAgent());
492-
$response = new MockResponse((object) $config);
498+
$request = new MockIncomingRequest($config, new URI($config->baseURL), null, new UserAgent());
499+
$response = new MockResponse($config);
493500

494501
$controller = new class($request, $response)
495502
{

0 commit comments

Comments
 (0)