@@ -62,7 +62,7 @@ protected function setUp(): void
62
62
->method ('get ' )
63
63
->with (ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME )
64
64
->willReturn ($ this ->_defaultFrontName );
65
- $ this ->uri = $ this ->createMock (Uri::class);
65
+ $ this ->uri = $ this ->createPartialMock (Uri::class, [ ' parse ' ] );
66
66
$ this ->request = $ this ->createMock (Http::class);
67
67
$ this ->configMock = $ this ->createMock (Config::class);
68
68
$ this ->scopeConfigMock = $ this ->createMock (ScopeConfigInterface::class);
@@ -149,34 +149,16 @@ public function testIsHostBackend(
149
149
->willReturnMap (
150
150
[
151
151
['HTTP_HOST ' , null , $ host ],
152
- ['REQUEST_SCHEME ' , null , $ isHttps ? 'https ' : 'http ' ],
153
152
]
154
153
);
154
+ $ this ->request ->method ('isSecure ' )
155
+ ->willReturn ($ isHttps );
155
156
156
- $ urlParts = [];
157
157
$ this ->uri ->method ('parse ' )
158
158
->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 ))
180
162
);
181
163
182
164
$ this ->assertEquals ($ expectedValue , $ this ->model ->isHostBackend ());
@@ -192,11 +174,8 @@ public function testIsHostBackendWithEmptyHost(): void
192
174
$ this ->request ->expects ($ this ->any ())
193
175
->method ('getServer ' )
194
176
->willReturn ('magento2.loc ' );
195
- $ this ->uri ->expects ($ this ->once ())
196
- ->method ('getHost ' )
197
- ->willReturn (null );
198
177
199
- $ this ->assertEquals ($ this ->model ->isHostBackend (), false );
178
+ $ this ->assertFalse ($ this ->model ->isHostBackend ());
200
179
}
201
180
202
181
/**
0 commit comments