diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 6ce808253a0a3..100b0722bddac 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -715,13 +715,10 @@ public function testGetManifest(): void { $this->urlGenerator ->expects($this->exactly(2)) ->method('linkToRoute') - ->withConsecutive( - ['theming.Icon.getTouchIcon', ['app' => 'core']], - ['theming.Icon.getFavicon', ['app' => 'core']], - )->willReturnOnConsecutiveCalls( - 'touchicon', - 'favicon', - ); + ->willReturnMap([ + ['theming.Icon.getTouchIcon', ['app' => 'core'], 'touchicon'], + ['theming.Icon.getFavicon', ['app' => 'core'], 'favicon'], + ]); $response = new Http\JSONResponse([ 'name' => 'Nextcloud', 'start_url' => 'localhost', diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php index 54e4e2a70ee43..a3fba874289ea 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -92,13 +92,10 @@ public function mockGetImage($key, $file) { ->willReturn(file_get_contents(__DIR__ . '/../../../tests/data/testimage.png')); $folder->expects($this->exactly(2)) ->method('fileExists') - ->withConsecutive( - ['logo'], - ['logo.png'], - )->willReturnOnConsecutiveCalls( - true, - false, - ); + ->willReturnMap([ + ['logo', true], + ['logo.png', false], + ]); $folder->expects($this->once()) ->method('getFile') ->with('logo') @@ -119,14 +116,12 @@ public function mockGetImage($key, $file) { public function testGetImageUrl(): void { $this->checkImagick(); - $file = $this->createMock(ISimpleFile::class); $this->config->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'logoMime', ''] - ) - ->willReturn(0); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '0'], + ['theming', 'logoMime', '', '0'], + ]); $this->urlGenerator->expects($this->once()) ->method('linkToRoute') ->willReturn('url-to-image'); @@ -136,11 +131,10 @@ public function testGetImageUrl(): void { public function testGetImageUrlDefault(): void { $this->config->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'logoMime', ''] - ) - ->willReturnOnConsecutiveCalls(0, ''); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '0'], + ['theming', 'logoMime', '', ''], + ]); $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('core', 'logo/logo.png') @@ -150,14 +144,12 @@ public function testGetImageUrlDefault(): void { public function testGetImageUrlAbsolute(): void { $this->checkImagick(); - $file = $this->createMock(ISimpleFile::class); $this->config->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'logoMime', ''] - ) - ->willReturnOnConsecutiveCalls(0, 0); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '0'], + ['theming', 'logoMime', '', ''], + ]); $this->urlGenerator->expects($this->any()) ->method('getAbsoluteUrl') ->willReturn('url-to-image-absolute?v=0'); diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index d8f169e7f3de0..349dd4f16f840 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -500,13 +500,18 @@ public function testGetColorPrimary(bool $disableTheming, string $primaryColor, } public function testSet(): void { + $expectedCalls = [ + ['theming', 'MySetting', 'MyValue'], + ['theming', 'cachebuster', 16], + ]; + $i = 0; $this->config ->expects($this->exactly(2)) ->method('setAppValue') - ->withConsecutive( - ['theming', 'MySetting', 'MyValue'], - ['theming', 'cachebuster', 16], - ); + ->willReturnCallback(function () use ($expectedCalls, &$i) { + $this->assertEquals($expectedCalls[$i], func_get_args()); + $i++; + }); $this->config ->expects($this->once()) ->method('getAppValue') @@ -515,11 +520,10 @@ public function testSet(): void { $this->cacheFactory ->expects($this->exactly(2)) ->method('createDistributed') - ->withConsecutive( - ['theming-'], - ['imagePath'], - ) - ->willReturn($this->cache); + ->willReturnMap([ + ['theming-', $this->cache], + ['imagePath', $this->cache], + ]); $this->cache ->expects($this->any()) ->method('clear') @@ -535,13 +539,10 @@ public function testUndoName(): void { $this->config ->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'name', 'Nextcloud'], - )->willReturnOnConsecutiveCalls( - '15', - 'Nextcloud', - ); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '15'], + ['theming', 'name', 'Nextcloud', 'Nextcloud'], + ]); $this->config ->expects($this->once()) ->method('setAppValue') @@ -558,13 +559,10 @@ public function testUndoBaseUrl(): void { $this->config ->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'url', $this->defaults->getBaseUrl()], - )->willReturnOnConsecutiveCalls( - '15', - $this->defaults->getBaseUrl(), - ); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '15'], + ['theming', 'url', $this->defaults->getBaseUrl(), $this->defaults->getBaseUrl()], + ]); $this->config ->expects($this->once()) ->method('setAppValue') @@ -581,13 +579,10 @@ public function testUndoSlogan(): void { $this->config ->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'cachebuster', '0'], - ['theming', 'slogan', $this->defaults->getSlogan()], - )->willReturnOnConsecutiveCalls( - '15', - $this->defaults->getSlogan(), - ); + ->willReturnMap([ + ['theming', 'cachebuster', '0', '15'], + ['theming', 'slogan', $this->defaults->getSlogan(), $this->defaults->getSlogan()], + ]); $this->config ->expects($this->once()) ->method('setAppValue') @@ -649,13 +644,10 @@ private function getLogoHelper($withName, $useSvg) { $this->config ->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'logoMime'], - ['theming', 'cachebuster', '0'], - )->willReturnOnConsecutiveCalls( - '', - '0' - ); + ->willReturnMap([ + ['theming', 'logoMime', '', ''], + ['theming', 'cachebuster', '0', '0'], + ]); $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('core', $withName) @@ -675,13 +667,10 @@ public function testGetLogoCustom(): void { $this->config ->expects($this->exactly(2)) ->method('getAppValue') - ->withConsecutive( - ['theming', 'logoMime', false], - ['theming', 'cachebuster', '0'], - )->willReturnOnConsecutiveCalls( - 'image/svg+xml', - '0', - ); + ->willReturnMap([ + ['theming', 'logoMime', '', 'image/svg+xml'], + ['theming', 'cachebuster', '0', '0'], + ]); $this->urlGenerator->expects($this->once()) ->method('linkToRoute') ->with('theming.Theming.getImage') @@ -710,7 +699,7 @@ public function testGetScssVariables(): void { ['theming', 'logoheaderMime', '', 'jpeg'], ['theming', 'faviconMime', '', 'jpeg'], ]); - + $this->appConfig ->expects(self::atLeastOnce()) ->method('getValueString') diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php index dccccf1a94025..3ebeb3d805d28 100644 --- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php +++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php @@ -93,14 +93,10 @@ public function testRun(): void { $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->withConsecutive( - ['has_internet_connection', true], - ['debug', false], - ) - ->willReturnOnConsecutiveCalls( - true, - true, - ); + ->willReturnMap([ + ['has_internet_connection', true, true], + ['debug', false, true], + ]); self::invokePrivate($job, 'run', [null]); } @@ -224,7 +220,7 @@ public function dataCheckAppUpdates(): array { ['app2', '1.9.2'], ], [ - ['app2', '1.9.2'], + ['app2', '1.9.2', ''], ], ], ]; @@ -251,9 +247,14 @@ public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array ->method('isUpdateAvailable') ->willReturnMap($isUpdateAvailable); - $mockedMethod = $job->expects($this->exactly(\count($notifications))) - ->method('createNotifications'); - \call_user_func_array([$mockedMethod, 'withConsecutive'], $notifications); + $i = 0; + $job->expects($this->exactly(\count($notifications))) + ->method('createNotifications') + ->willReturnCallback(function () use ($notifications, &$i) { + $this->assertEquals($notifications[$i], func_get_args()); + $i++; + }); + self::invokePrivate($job, 'checkAppUpdates'); } @@ -331,10 +332,9 @@ public function testCreateNotifications(string $app, string $version, $lastNotif ->willReturnSelf(); if ($userNotifications !== null) { - $mockedMethod = $notification->expects($this->exactly(\count($userNotifications))) + $notification->expects($this->exactly(\count($userNotifications))) ->method('setUser') ->willReturnSelf(); - \call_user_func_array([$mockedMethod, 'withConsecutive'], $userNotifications); $this->notificationManager->expects($this->exactly(\count($userNotifications))) ->method('notify');