fix(ci): Remove more withConsecutive in apps

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/48234/head
Joas Schilling 2 years ago
parent 4ba3d4a31a
commit 0e07c310a1
No known key found for this signature in database
GPG Key ID: F72FA5B49FFA96B0
  1. 11
      apps/theming/tests/Controller/ThemingControllerTest.php
  2. 40
      apps/theming/tests/ImageManagerTest.php
  3. 79
      apps/theming/tests/ThemingDefaultsTest.php
  4. 28
      apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.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',

@ -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');

@ -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')

@ -93,14 +93,10 @@ class UpdateAvailableNotificationsTest extends TestCase {
$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 @@ class UpdateAvailableNotificationsTest extends TestCase {
['app2', '1.9.2'],
],
[
['app2', '1.9.2'],
['app2', '1.9.2', ''],
],
],
];
@ -251,9 +247,14 @@ class UpdateAvailableNotificationsTest extends TestCase {
->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 @@ class UpdateAvailableNotificationsTest extends TestCase {
->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');

Loading…
Cancel
Save