diff options
author | Joas Schilling <coding@schilljs.com> | 2024-09-20 10:23:47 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-09-20 10:23:47 +0200 |
commit | 0e07c310a17bdc55a41e00c29b10a579e1b5c423 (patch) | |
tree | 3c60e394bb5621f0426aacee000ff16cb7116031 /apps/theming/tests | |
parent | 4ba3d4a31a5a27a7fad6b8928d899ec7247289ca (diff) | |
download | nextcloud-server-0e07c310a17bdc55a41e00c29b10a579e1b5c423.tar.gz nextcloud-server-0e07c310a17bdc55a41e00c29b10a579e1b5c423.zip |
fix(ci): Remove more withConsecutive in appsbugfix/noid/remove-more-withConsecutive
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 11 | ||||
-rw-r--r-- | apps/theming/tests/ImageManagerTest.php | 40 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 79 |
3 files changed, 54 insertions, 76 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index 6ce808253a0..100b0722bdd 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -715,13 +715,10 @@ class ThemingControllerTest extends TestCase { $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 54e4e2a70ee..a3fba874289 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -92,13 +92,10 @@ class ImageManagerTest extends TestCase { ->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 @@ class ImageManagerTest extends TestCase { 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 @@ class ImageManagerTest extends TestCase { 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 @@ class ImageManagerTest extends TestCase { 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 d8f169e7f3d..349dd4f16f8 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -500,13 +500,18 @@ class ThemingDefaultsTest extends TestCase { } 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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { $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 @@ class ThemingDefaultsTest extends TestCase { ['theming', 'logoheaderMime', '', 'jpeg'], ['theming', 'faviconMime', '', 'jpeg'], ]); - + $this->appConfig ->expects(self::atLeastOnce()) ->method('getValueString') |