88use CodeIgniter \Test \CIUnitTestCase ;
99use CodeIgniter \Test \Mock \MockIncomingRequest ;
1010use CodeIgniter \Test \Mock \MockResponse ;
11+ use Config \App ;
1112use stdClass ;
1213
1314class 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