Skip to content

Commit 9a2cf47

Browse files
committed
test: remove legacy onConsecutive handling
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent c915414 commit 9a2cf47

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

tests/Unit/RollbackServiceTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,14 @@ public function testRollbackOlderThan(): void {
119119
$userFolder7 = $this->createMock(Folder::class);
120120

121121
$this->rootFolder->method('getUserFolder')
122-
->withConsecutive(['user2'], ['user3'], ['user4'], ['user5'], ['user6'], ['user7'])
123-
->willReturnOnConsecutiveCalls(
124-
$this->throwException(new \Exception('User not found')),
125-
$userFolder3,
126-
$userFolder4,
127-
$userFolder5,
128-
$userFolder6,
129-
$userFolder7
130-
);
122+
->willReturnCallback(fn (string $userId) => match ($userId) {
123+
'user2' => throw new \Exception('User not found'),
124+
'user3' => $userFolder3,
125+
'user4' => $userFolder4,
126+
'user5' => $userFolder5,
127+
'user6' => $userFolder6,
128+
'user7' => $userFolder7,
129+
});
131130

132131
$node3 = $this->createMock(Folder::class);
133132
$node3->expects($this->once())
@@ -165,29 +164,30 @@ public function testRollbackOlderThan(): void {
165164

166165
$this->fileService->expects($this->exactly(3))
167166
->method('revertChanges')
168-
->withConsecutive([$node4], [$node5], [$node6])
169-
->willReturnOnConsecutiveCalls(
170-
$this->throwException(new \Exception('Exception while reverting changes')),
171-
true,
172-
true
173-
);
167+
->willReturnCallback(fn (Folder $folder) => match ($folder) {
168+
$node4 => throw new \Exception('Exception while reverting changes'),
169+
$node5 => true,
170+
$node6 => true,
171+
});
174172

175173
$this->metaDataStorage->expects($this->exactly(2))
176174
->method('deleteIntermediateFile')
177-
->withConsecutive(['user5', 100005], ['user6', 100006])
178-
->willReturnOnConsecutiveCalls(
179-
$this->throwException(new \Exception('Exception while deleting intermediate file')),
180-
null
181-
);
175+
->willReturnCallback(fn (string $userId, int $fileId) => match ([$userId, $fileId]) {
176+
['user5', 100005] => throw new \Exception('Exception while deleting intermediate file'),
177+
['user6', 100006] => null,
178+
});
179+
$this->logger->expects($this->exactly(3))
180+
->method('critical');
182181

182+
$calls = [];
183183
$this->lockMapper->expects($this->exactly(3))
184184
->method('delete')
185-
->withConsecutive([$locks[0]], [$locks[5]], [$locks[6]]);
186-
187-
$this->logger->expects($this->exactly(3))
188-
->method('critical');
185+
->willReturnCallback(function (Lock $lock) use (&$calls) {
186+
$calls[] = $lock;
187+
});
189188

190189
$this->rollbackService->rollbackOlderThan(1337, 10);
190+
$this->assertEquals([$locks[0], $locks[5], $locks[6]], $calls);
191191
}
192192

193193
private function getSampleLocks(): array {

0 commit comments

Comments
 (0)