Skip to content

Commit 7d712b2

Browse files
committed
38554: Fix unit test case
1 parent cc3bcc2 commit 7d712b2

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php

100644100755
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ protected function setUp(): void
8282
*/
8383
public function testIfCustomPathUsed(): void
8484
{
85-
$this->configMock
85+
$this->configMock->expects($this->once())
86+
->method('isSetFlag')
87+
->with(FrontNameResolver::XML_PATH_USE_CUSTOM_ADMIN_PATH)
88+
->willReturn(true);
89+
90+
$this->configMock->expects($this->once())
8691
->method('getValue')
87-
->willReturnCallback(fn($param) => match ([$param]) {
88-
['admin/url/use_custom_path'] => true,
89-
['admin/url/custom_path'] => 'expectedValue'
90-
});
92+
->with(FrontNameResolver::XML_PATH_CUSTOM_ADMIN_PATH)
93+
->willReturn('expectedValue');
94+
9195
$this->assertEquals('expectedValue', $this->model->getFrontName());
9296
}
9397

@@ -96,15 +100,11 @@ public function testIfCustomPathUsed(): void
96100
*/
97101
public function testIfCustomPathNotUsed(): void
98102
{
99-
$this->configMock->expects(
100-
$this->once()
101-
)->method(
102-
'getValue'
103-
)->with(
104-
'admin/url/use_custom_path'
105-
)->willReturn(
106-
false
107-
);
103+
$this->configMock->expects($this->once())
104+
->method('isSetFlag')
105+
->with(FrontNameResolver::XML_PATH_USE_CUSTOM_ADMIN_PATH)
106+
->willReturn(false);
107+
108108
$this->assertEquals($this->_defaultFrontName, $this->model->getFrontName());
109109
}
110110

@@ -125,7 +125,11 @@ public function testIsHostBackend(
125125
string $customAdminUrl,
126126
bool $expectedValue
127127
): void {
128-
$this->scopeConfigMock->expects($this->exactly(2))
128+
$this->scopeConfigMock->expects($this->once())
129+
->method('isSetFlag')
130+
->willReturn($useCustomAdminUrl);
131+
132+
$this->scopeConfigMock->expects($this->once())
129133
->method('getValue')
130134
->willReturnMap(
131135
[
@@ -138,7 +142,7 @@ public function testIsHostBackend(
138142
],
139143
[
140144
FrontNameResolver::XML_PATH_CUSTOM_ADMIN_URL,
141-
ScopeInterface::SCOPE_STORE,
145+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
142146
null,
143147
$customAdminUrl
144148
]
@@ -179,7 +183,7 @@ function () use (&$urlParts) {
179183
}
180184
);
181185

182-
$this->assertEquals($this->model->isHostBackend(), $expectedValue);
186+
$this->assertEquals($expectedValue, $this->model->isHostBackend());
183187
}
184188

185189
/**

0 commit comments

Comments
 (0)