Skip to content

Commit

Permalink
Remove deprecated at matcher from theming tests
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Jun 16, 2022
1 parent 0c14ee6 commit f8a5be6
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 134 deletions.
50 changes: 25 additions & 25 deletions apps/theming/tests/Controller/ThemingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ public function testUpdateStylesheetError($setting, $value, $message) {

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);
Expand Down Expand Up @@ -251,12 +251,12 @@ public function testUploadSVGFaviconWithoutImagemagick() {
->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([
Expand Down Expand Up @@ -292,12 +292,12 @@ public function testUploadSVGFaviconWithoutImagemagick() {

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([
Expand Down Expand Up @@ -350,12 +350,12 @@ public function testUpdateLogoNormalLogoUpload($mimeType, $folderExists = true)
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([
Expand Down Expand Up @@ -401,12 +401,12 @@ public function testUpdateLogoLoginScreenUpload($folderExists) {
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([
Expand Down Expand Up @@ -449,12 +449,12 @@ public function testUpdateLogoLoginScreenUploadWithInvalidImage() {
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([
Expand Down Expand Up @@ -504,12 +504,12 @@ public function dataPhpUploadErrors() {
*/
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([
Expand Down Expand Up @@ -543,12 +543,12 @@ public function testUpdateLogoLoginScreenUploadWithInvalidImageUpload($error, $e
*/
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([
Expand Down Expand Up @@ -713,19 +713,19 @@ public function testGetManifest() {
->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',
Expand Down
35 changes: 18 additions & 17 deletions apps/theming/tests/ImageManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,21 @@ public function mockGetImage($key, $file) {
$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);
Expand Down Expand Up @@ -211,15 +212,15 @@ public function testGetCacheFolderCreate() {
->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())
Expand Down Expand Up @@ -290,7 +291,7 @@ private function setupCacheFolder() {
->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);
Expand Down
10 changes: 5 additions & 5 deletions apps/theming/tests/Settings/PersonalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ public function testGetForm(string $enforcedTheme, $themesState) {
->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());
Expand Down
Loading

0 comments on commit f8a5be6

Please sign in to comment.