@@ -62,7 +62,7 @@ protected function setUp(): void
6262 ->method ('get ' )
6363 ->with (ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME )
6464 ->willReturn ($ this ->_defaultFrontName );
65- $ this ->uri = $ this ->createMock (Uri::class);
65+ $ this ->uri = $ this ->createPartialMock (Uri::class, [ ' parse ' ] );
6666 $ this ->request = $ this ->createMock (Http::class);
6767 $ this ->configMock = $ this ->createMock (Config::class);
6868 $ this ->scopeConfigMock = $ this ->createMock (ScopeConfigInterface::class);
@@ -149,34 +149,16 @@ public function testIsHostBackend(
149149 ->willReturnMap (
150150 [
151151 ['HTTP_HOST ' , null , $ host ],
152- ['REQUEST_SCHEME ' , null , $ isHttps ? 'https ' : 'http ' ],
153152 ]
154153 );
154+ $ this ->request ->method ('isSecure ' )
155+ ->willReturn ($ isHttps );
155156
156- $ urlParts = [];
157157 $ this ->uri ->method ('parse ' )
158158 ->willReturnCallback (
159- function ($ url ) use (&$ urlParts ) {
160- $ urlParts = parse_url ($ url );
161- }
162- );
163- $ this ->uri ->method ('getScheme ' )
164- ->willReturnCallback (
165- function () use (&$ urlParts ) {
166- return array_key_exists ('scheme ' , $ urlParts ) ? $ urlParts ['scheme ' ] : '' ;
167- }
168- );
169- $ this ->uri ->method ('getHost ' )
170- ->willReturnCallback (
171- function () use (&$ urlParts ) {
172- return array_key_exists ('host ' , $ urlParts ) ? $ urlParts ['host ' ] : '' ;
173- }
174- );
175- $ this ->uri ->method ('getPort ' )
176- ->willReturnCallback (
177- function () use (&$ urlParts ) {
178- return array_key_exists ('port ' , $ urlParts ) ? $ urlParts ['port ' ] : '' ;
179- }
159+ fn ($ url ) => $ this ->uri ->setScheme (parse_url ($ url , PHP_URL_SCHEME ))
160+ ->setHost (parse_url ($ url , PHP_URL_HOST ))
161+ ->setPort (parse_url ($ url , PHP_URL_PORT ))
180162 );
181163
182164 $ this ->assertEquals ($ expectedValue , $ this ->model ->isHostBackend ());
@@ -192,11 +174,8 @@ public function testIsHostBackendWithEmptyHost(): void
192174 $ this ->request ->expects ($ this ->any ())
193175 ->method ('getServer ' )
194176 ->willReturn ('magento2.loc ' );
195- $ this ->uri ->expects ($ this ->once ())
196- ->method ('getHost ' )
197- ->willReturn (null );
198177
199- $ this ->assertEquals ($ this ->model ->isHostBackend (), false );
178+ $ this ->assertFalse ($ this ->model ->isHostBackend ());
200179 }
201180
202181 /**
0 commit comments