Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-06-16 16:55:05 +0300
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-06-16 16:55:05 +0300
commitf8a5be6a9071b3b9704242ee65f8b3a21402abe9 (patch)
tree750b7333e959bec51cbbfc9b0d754d40ba0566c3 /apps/theming
parent0c14ee6ff5a2d3aa3f77f8cd2bf331590ee62f44 (diff)
Remove deprecated at matcher from theming tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php50
-rw-r--r--apps/theming/tests/ImageManagerTest.php35
-rw-r--r--apps/theming/tests/Settings/PersonalTest.php10
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php177
4 files changed, 138 insertions, 134 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index 511f7a6d528..9042a338fb7 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -208,12 +208,12 @@ class ThemingControllerTest extends TestCase {
public function testUpdateLogoNoData() {
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('logo');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn(null);
@@ -251,12 +251,12 @@ class ThemingControllerTest extends TestCase {
->willReturn(false);
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('favicon');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -292,12 +292,12 @@ class ThemingControllerTest extends TestCase {
public function testUpdateLogoInvalidMimeType() {
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('logo');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -350,12 +350,12 @@ class ThemingControllerTest extends TestCase {
touch($tmpLogo);
copy(__DIR__ . '/../../../../tests/data/testimage.png', $tmpLogo);
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('logo');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -401,12 +401,12 @@ class ThemingControllerTest extends TestCase {
touch($tmpLogo);
copy(__DIR__ . '/../../../../tests/data/desktopapp.png', $tmpLogo);
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('background');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -449,12 +449,12 @@ class ThemingControllerTest extends TestCase {
touch($tmpLogo);
file_put_contents($tmpLogo, file_get_contents(__DIR__ . '/../../../../tests/data/data.zip'));
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('logo');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -504,12 +504,12 @@ class ThemingControllerTest extends TestCase {
*/
public function testUpdateLogoLoginScreenUploadWithInvalidImageUpload($error, $expectedErrorMessage) {
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('background');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -543,12 +543,12 @@ class ThemingControllerTest extends TestCase {
*/
public function testUpdateLogoUploadWithInvalidImageUpload($error, $expectedErrorMessage) {
$this->request
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getParam')
->with('key')
->willReturn('background');
$this->request
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getUploadedFile')
->with('image')
->willReturn([
@@ -713,19 +713,19 @@ class ThemingControllerTest extends TestCase {
->method('getName')
->willReturn('Nextcloud');
$this->urlGenerator
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getBaseUrl')
->willReturn('localhost');
$this->urlGenerator
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('linkToRoute')
- ->with('theming.Icon.getTouchIcon', ['app' => 'core'])
- ->willReturn('touchicon');
- $this->urlGenerator
- ->expects($this->at(2))
- ->method('linkToRoute')
- ->with('theming.Icon.getFavicon', ['app' => 'core'])
- ->willReturn('favicon');
+ ->withConsecutive(
+ ['theming.Icon.getTouchIcon', ['app' => 'core']],
+ ['theming.Icon.getFavicon', ['app' => 'core']],
+ )->willReturnOnConsecutiveCalls(
+ 'touchicon',
+ '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 10faf6c1da1..6a9b77234bb 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -100,20 +100,21 @@ class ImageManagerTest extends TestCase {
$file->expects($this->once())
->method('getContent')
->willReturn(file_get_contents(__DIR__ . '/../../../tests/data/testimage.png'));
- $folder->expects($this->at(0))
+ $folder->expects($this->exactly(2))
->method('fileExists')
- ->with('logo')
- ->willReturn(true);
- $folder->expects($this->at(1))
- ->method('fileExists')
- ->with('logo.png')
- ->willReturn(false);
- $folder->expects($this->at(2))
+ ->withConsecutive(
+ ['logo'],
+ ['logo.png'],
+ )->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ );
+ $folder->expects($this->once())
->method('getFile')
->with('logo')
->willReturn($file);
$newFile = $this->createMock(ISimpleFile::class);
- $folder->expects($this->at(3))
+ $folder->expects($this->once())
->method('newFile')
->with('logo.png')
->willReturn($newFile);
@@ -211,15 +212,15 @@ class ImageManagerTest extends TestCase {
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
- $this->appData->expects($this->at(0))
+ $this->appData->expects($this->exactly(2))
->method('getFolder')
- ->willThrowException(new NotFoundException());
- $this->appData->expects($this->at(1))
- ->method('newFolder')
->with('0')
- ->willReturn($folder);
- $this->appData->expects($this->at(2))
- ->method('getFolder')
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new NotFoundException()),
+ $folder,
+ );
+ $this->appData->expects($this->once())
+ ->method('newFolder')
->with('0')
->willReturn($folder);
$this->appData->expects($this->once())
@@ -290,7 +291,7 @@ class ImageManagerTest extends TestCase {
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
- $this->appData->expects($this->at(0))
+ $this->appData->expects($this->once())
->method('getFolder')
->with('0')
->willReturn($folder);
diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php
index 5f0585911bb..a5409e5f57a 100644
--- a/apps/theming/tests/Settings/PersonalTest.php
+++ b/apps/theming/tests/Settings/PersonalTest.php
@@ -110,12 +110,12 @@ class PersonalTest extends TestCase {
->with('enforce_theme', '')
->willReturn($enforcedTheme);
- $this->initialStateService->expects($this->at(0))
+ $this->initialStateService->expects($this->exactly(2))
->method('provideInitialState')
- ->with('themes', $themesState);
- $this->initialStateService->expects($this->at(1))
- ->method('provideInitialState')
- ->with('enforceTheme', $enforcedTheme);
+ ->withConsecutive(
+ ['themes', $themesState],
+ ['enforceTheme', $enforcedTheme],
+ );
$expected = new TemplateResponse('theming', 'settings-personal');
$this->assertEquals($expected, $this->admin->getForm());
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index c8ef147dc94..20c153f1e96 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -437,27 +437,24 @@ class ThemingDefaultsTest extends TestCase {
public function testSet() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('theming', 'MySetting', 'MyValue');
+ ->withConsecutive(
+ ['theming', 'MySetting', 'MyValue'],
+ ['theming', 'cachebuster', 16],
+ );
$this->config
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('15');
- $this->config
- ->expects($this->at(2))
- ->method('setAppValue')
- ->with('theming', 'cachebuster', 16);
$this->cacheFactory
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('createDistributed')
- ->with('theming-')
- ->willReturn($this->cache);
- $this->cacheFactory
- ->expects($this->at(1))
- ->method('createDistributed')
- ->with('imagePath')
+ ->withConsecutive(
+ ['theming-'],
+ ['imagePath'],
+ )
->willReturn($this->cache);
$this->cache
->expects($this->any())
@@ -468,108 +465,108 @@ class ThemingDefaultsTest extends TestCase {
public function testUndoName() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('deleteAppValue')
->with('theming', 'name');
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('15');
+ ->withConsecutive(
+ ['theming', 'cachebuster', '0'],
+ ['theming', 'name', 'Nextcloud'],
+ )->willReturnOnConsecutiveCalls(
+ '15',
+ 'Nextcloud',
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('setAppValue')
->with('theming', 'cachebuster', 16);
- $this->config
- ->expects($this->at(3))
- ->method('getAppValue')
- ->with('theming', 'name', 'Nextcloud')
- ->willReturn('Nextcloud');
$this->assertSame('Nextcloud', $this->template->undo('name'));
}
public function testUndoBaseUrl() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('deleteAppValue')
->with('theming', 'url');
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('15');
+ ->withConsecutive(
+ ['theming', 'cachebuster', '0'],
+ ['theming', 'url', $this->defaults->getBaseUrl()],
+ )->willReturnOnConsecutiveCalls(
+ '15',
+ $this->defaults->getBaseUrl(),
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('setAppValue')
->with('theming', 'cachebuster', 16);
- $this->config
- ->expects($this->at(3))
- ->method('getAppValue')
- ->with('theming', 'url', $this->defaults->getBaseUrl())
- ->willReturn($this->defaults->getBaseUrl());
$this->assertSame($this->defaults->getBaseUrl(), $this->template->undo('url'));
}
public function testUndoSlogan() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('deleteAppValue')
->with('theming', 'slogan');
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('15');
+ ->withConsecutive(
+ ['theming', 'cachebuster', '0'],
+ ['theming', 'slogan', $this->defaults->getSlogan()],
+ )->willReturnOnConsecutiveCalls(
+ '15',
+ $this->defaults->getSlogan(),
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('setAppValue')
->with('theming', 'cachebuster', 16);
- $this->config
- ->expects($this->at(3))
- ->method('getAppValue')
- ->with('theming', 'slogan', $this->defaults->getSlogan())
- ->willReturn($this->defaults->getSlogan());
$this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
}
public function testUndoColor() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('deleteAppValue')
->with('theming', 'color');
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('15');
+ ->withConsecutive(
+ ['theming', 'cachebuster', '0'],
+ ['theming', 'color', $this->defaults->getColorPrimary()],
+ )->willReturnOnConsecutiveCalls(
+ '15',
+ $this->defaults->getColorPrimary(),
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('setAppValue')
->with('theming', 'cachebuster', 16);
- $this->config
- ->expects($this->at(3))
- ->method('getAppValue')
- ->with('theming', 'color', $this->defaults->getColorPrimary())
- ->willReturn($this->defaults->getColorPrimary());
$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('color'));
}
public function testUndoDefaultAction() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('deleteAppValue')
->with('theming', 'defaultitem');
$this->config
- ->expects($this->at(1))
+ ->expects($this->once())
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('15');
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('setAppValue')
->with('theming', 'cachebuster', 16);
@@ -591,15 +588,15 @@ class ThemingDefaultsTest extends TestCase {
->with('logo')
->willThrowException(new NotFoundException());
$this->config
- ->expects($this->at(0))
- ->method('getAppValue')
- ->with('theming', 'logoMime')
- ->willReturn('');
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('0');
+ ->withConsecutive(
+ ['theming', 'logoMime'],
+ ['theming', 'cachebuster', '0'],
+ )->willReturnOnConsecutiveCalls(
+ '',
+ '0'
+ );
$this->urlGenerator->expects($this->once())
->method('imagePath')
->with('core', $withName)
@@ -617,15 +614,15 @@ class ThemingDefaultsTest extends TestCase {
public function testGetLogoCustom() {
$this->config
- ->expects($this->at(0))
- ->method('getAppValue')
- ->with('theming', 'logoMime', false)
- ->willReturn('image/svg+xml');
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('theming', 'cachebuster', '0')
- ->willReturn('0');
+ ->withConsecutive(
+ ['theming', 'logoMime', false],
+ ['theming', 'cachebuster', '0'],
+ )->willReturnOnConsecutiveCalls(
+ 'image/svg+xml',
+ '0',
+ );
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->with('theming.Theming.getImage')
@@ -644,16 +641,18 @@ class ThemingDefaultsTest extends TestCase {
}
public function testGetScssVariables() {
- $this->config->expects($this->at(0))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0');
- $this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg');
- $this->config->expects($this->at(2))->method('getAppValue')->with('theming', 'backgroundMime', false)->willReturn('jpeg');
- $this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'logoheaderMime', false)->willReturn('jpeg');
- $this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'faviconMime', false)->willReturn('jpeg');
-
- $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary());
- $this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
- $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
- $this->config->expects($this->at(8))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary());
+ $this->config
+ ->expects($this->any())
+ ->method('getAppValue')
+ ->willReturnMap([
+ ['theming', 'cachebuster', '0', '0'],
+ ['theming', 'logoMime', '', 'jpeg'],
+ ['theming', 'backgroundMime', '', 'jpeg'],
+ ['theming', 'logoheaderMime', '', 'jpeg'],
+ ['theming', 'faviconMime', '', 'jpeg'],
+ ['theming', 'color', '', $this->defaults->getColorPrimary()],
+ ['theming', 'color', $this->defaults->getColorPrimary(), $this->defaults->getColorPrimary()],
+ ]);
$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
@@ -662,10 +661,14 @@ class ThemingDefaultsTest extends TestCase {
->with('theming-0-')
->willReturn($this->cache);
$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
- $this->imageManager->expects($this->at(0))->method('getImageUrl')->with('logo')->willReturn('custom-logo?v=0');
- $this->imageManager->expects($this->at(1))->method('getImageUrl')->with('logoheader')->willReturn('custom-logoheader?v=0');
- $this->imageManager->expects($this->at(2))->method('getImageUrl')->with('favicon')->willReturn('custom-favicon?v=0');
- $this->imageManager->expects($this->at(3))->method('getImageUrl')->with('background')->willReturn('custom-background?v=0');
+ $this->imageManager->expects($this->exactly(4))
+ ->method('getImageUrl')
+ ->willReturnMap([
+ ['logo', true, 'custom-logo?v=0'],
+ ['logoheader', true, 'custom-logoheader?v=0'],
+ ['favicon', true, 'custom-favicon?v=0'],
+ ['background', true, 'custom-background?v=0'],
+ ]);
$expected = [
'theming-cachebuster' => '\'0\'',