Skip to content

Commit 1db7144

Browse files
committed
AC-15049 : [CE] PHPUnit 12: fix automated test faliure
1 parent 11d0bfa commit 1db7144

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

app/code/Magento/Security/Test/Unit/Model/ResourceModel/AdminSessionInfoTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,9 @@ public function testUpdateStatusByUserId()
8787
$whereStatement = [
8888
'updated_at > ?' => $this->dateTimeMock->formatDate($updateOlderThen),
8989
'user_id = ?' => (int) $userId,
90+
'id NOT IN (?)' => $excludedSessionIds,
91+
'status IN (?)' => $withStatuses,
9092
];
91-
if (!empty($excludedSessionIds)) {
92-
$whereStatement['id NOT IN (?)'] = $excludedSessionIds;
93-
}
94-
if (!empty($withStatuses)) {
95-
$whereStatement['status IN (?)'] = $withStatuses;
96-
}
9793

9894
$this->resourceMock->expects($this->once())
9995
->method('getConnection')

app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/DeleteTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,25 @@ public function testExecute($currentUserPassword, $userId, $currentUserId, $resu
136136

137137
$this->requestMock->expects($this->any())
138138
->method('getPost')
139-
->willReturnMap([
140-
['user_id', $userId],
141-
[Main::CURRENT_USER_PASSWORD_FIELD, $currentUserPassword],
142-
]);
139+
->willReturnCallback(function ($key) use ($userId, $currentUserPassword) {
140+
if ($key === 'user_id') {
141+
return $userId;
142+
}
143+
if ($key === Main::CURRENT_USER_PASSWORD_FIELD) {
144+
return $currentUserPassword;
145+
}
146+
return null;
147+
});
143148

144149
$userMock = clone $currentUserMock;
145150

151+
if ($resultMethod === 'addSuccess' && $userId && $currentUserId !== $userId) {
152+
$currentUserMock->expects($this->once())
153+
->method('performIdentityCheck')
154+
->with($currentUserPassword)
155+
->willReturn(true);
156+
}
157+
146158
$this->userFactoryMock->expects($this->any())->method('create')->willReturn($userMock);
147159
$this->responseMock->expects($this->any())->method('setRedirect')->willReturnSelf();
148160
$this->userMock->expects($this->any())->method('delete')->willReturnSelf();

0 commit comments

Comments
 (0)