From 0a301168aa4fde73d0430d78bc458d545aca1c03 Mon Sep 17 00:00:00 2001
From: Torben Hansen <derhansen@gmail.com>
Date: Tue, 21 Mar 2023 18:54:24 +0100
Subject: [PATCH] [TASK] Replace withConsecutive() call in ext:adminpanel test

This change replaces a `withConsecutive()` call in a test
by using a callback function to check for expected
arguments in no explicit order.

(`withConsecutive()` is deprecated in PHPUnit 9.6 and removed
from PHPUnit 10.)

Resolves: #100241
Related: #100249
Releases: main
Signed-off-by: Torben Hansen <derhansen@gmail.com>
Change-Id: Ia9b7ca62f052210fb3cc2a310fe55c31c3e8f889
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78201
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Tests/Unit/Modules/PreviewModuleTest.php       | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/typo3/sysext/adminpanel/Tests/Unit/Modules/PreviewModuleTest.php b/typo3/sysext/adminpanel/Tests/Unit/Modules/PreviewModuleTest.php
index 865bc223ccb2..d7b52a04fa1f 100644
--- a/typo3/sysext/adminpanel/Tests/Unit/Modules/PreviewModuleTest.php
+++ b/typo3/sysext/adminpanel/Tests/Unit/Modules/PreviewModuleTest.php
@@ -93,13 +93,13 @@ class PreviewModuleTest extends UnitTestCase
         $context = $this->getMockBuilder(Context::class)->getMock();
         $context->method('hasAspect')->with('frontend.preview')->willReturn(false);
         $context->expects(self::any())->method('setAspect')
-            ->withConsecutive(
-                ['date', self::anything()],
-                ['visibility', self::anything()],
-                ['visibility', self::anything()],
-                ['frontend.user', self::anything()],
-                ['frontend.preview', self::anything()],
-            );
+            ->willReturnCallback(fn (string $name): bool => match (true) {
+                $name === 'date',
+                $name === 'visibility',
+                $name === 'frontend.user',
+                $name === 'frontend.preview' => true,
+                default => throw new \LogicException('Unexpected argument "' . $name . '" provided.', 1679482900),
+            });
         GeneralUtility::setSingletonInstance(Context::class, $context);
 
         $previewModule = new PreviewModule();
-- 
GitLab