]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove at() matcher in files_sharing tests 32577/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 24 May 2022 13:20:52 +0000 (15:20 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 24 May 2022 13:20:52 +0000 (15:20 +0200)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
apps/files_sharing/tests/Controller/ShareControllerTest.php
apps/files_sharing/tests/External/ManagerTest.php
apps/files_sharing/tests/MountProviderTest.php

index 55f719b8f889d7156d743f5f6d993482dba89bf3..cc7fcabe5ace0220d73a38f82fe3f895dab0279b 100644 (file)
@@ -186,19 +186,15 @@ class CleanupRemoteStoragesTest extends TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               //
-
                // parent folder, `files`, ´test` and `welcome.txt` => 4 elements
 
-               $at = 0;
-               $output
-                       ->expects($this->at($at++))
-                       ->method('writeln')
-                       ->with('5 remote storage(s) need(s) to be checked');
                $output
-                       ->expects($this->at($at++))
+                       ->expects($this->any())
                        ->method('writeln')
-                       ->with('5 remote share(s) exist');
+                       ->withConsecutive(
+                               ['5 remote storage(s) need(s) to be checked'],
+                               ['5 remote share(s) exist'],
+                       );
 
                $this->cloudIdManager
                        ->expects($this->any())
index 04d2a08b4e654a6f526401e86f0972027a1ff6d2..781372b889e3b219b092103b05b7d5450c443321 100644 (file)
@@ -263,10 +263,17 @@ class ShareControllerTest extends \Test\TestCase {
                $this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
                $this->session->method('get')->with('public_link_authenticated')->willReturn('42');
 
-               $this->urlGenerator->expects($this->at(0))
+               $this->urlGenerator->expects($this->exactly(3))
                        ->method('linkToRouteAbsolute')
-                       ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename])
-                       ->willReturn('downloadURL');
+                       ->withConsecutive(
+                               ['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]],
+                               ['files_sharing.sharecontroller.showShare', ['token' => 'token']],
+                               ['files_sharing.PublicPreview.getPreview', ['token' => 'token', 'x' => 200, 'y' => 200, 'file' => '/'.$filename]],
+                       )->willReturnOnConsecutiveCalls(
+                               'downloadURL',
+                               'shareUrl',
+                               'previewImage',
+                       );
 
                $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
 
@@ -343,8 +350,8 @@ class ShareControllerTest extends \Test\TestCase {
                        'hideFileList' => false,
                        'shareOwner' => 'ownerDisplay',
                        'disclaimer' => 'My disclaimer text',
-                       'shareUrl' => null,
-                       'previewImage' => null,
+                       'shareUrl' => 'shareUrl',
+                       'previewImage' => 'previewImage',
                        'previewURL' => 'downloadURL',
                        'note' => $note,
                        'hideDownload' => false,
@@ -414,10 +421,17 @@ class ShareControllerTest extends \Test\TestCase {
                $this->session->method('exists')->with('public_link_authenticated')->willReturn(true);
                $this->session->method('get')->with('public_link_authenticated')->willReturn('42');
 
-               $this->urlGenerator->expects($this->at(0))
+               $this->urlGenerator->expects($this->exactly(3))
                        ->method('linkToRouteAbsolute')
-                       ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename])
-                       ->willReturn('downloadURL');
+                       ->withConsecutive(
+                               ['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]],
+                               ['files_sharing.sharecontroller.showShare', ['token' => 'token']],
+                               ['files_sharing.PublicPreview.getPreview', ['token' => 'token', 'x' => 200, 'y' => 200, 'file' => '/'.$filename]],
+                       )->willReturnOnConsecutiveCalls(
+                               'downloadURL',
+                               'shareUrl',
+                               'previewImage',
+                       );
 
                $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
 
@@ -494,8 +508,8 @@ class ShareControllerTest extends \Test\TestCase {
                        'hideFileList' => false,
                        'shareOwner' => '',
                        'disclaimer' => 'My disclaimer text',
-                       'shareUrl' => null,
-                       'previewImage' => null,
+                       'shareUrl' => 'shareUrl',
+                       'previewImage' => 'previewImage',
                        'previewURL' => 'downloadURL',
                        'note' => $note,
                        'hideDownload' => false,
@@ -569,10 +583,17 @@ class ShareControllerTest extends \Test\TestCase {
                // Even if downloads are disabled the "downloadURL" parameter is
                // provided to the template, as it is needed to preview audio and GIF
                // files.
-               $this->urlGenerator->expects($this->at(0))
+               $this->urlGenerator->expects($this->exactly(3))
                        ->method('linkToRouteAbsolute')
-                       ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename])
-                       ->willReturn('downloadURL');
+                       ->withConsecutive(
+                               ['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename]],
+                               ['files_sharing.sharecontroller.showShare', ['token' => 'token']],
+                               ['files_sharing.PublicPreview.getPreview', ['token' => 'token', 'x' => 200, 'y' => 200, 'file' => '/'.$filename]],
+                       )->willReturnOnConsecutiveCalls(
+                               'downloadURL',
+                               'shareUrl',
+                               'previewImage',
+                       );
 
                $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
 
@@ -645,8 +666,8 @@ class ShareControllerTest extends \Test\TestCase {
                        'hideFileList' => false,
                        'shareOwner' => 'ownerDisplay',
                        'disclaimer' => 'My disclaimer text',
-                       'shareUrl' => null,
-                       'previewImage' => null,
+                       'shareUrl' => 'shareUrl',
+                       'previewImage' => 'previewImage',
                        'previewURL' => 'downloadURL',
                        'note' => $note,
                        'hideDownload' => true,
index 307b630970f2994b9d57fe6c5e801b64820d6977..0b35e08da2d04de465ab46eea00867b24e3f5496 100644 (file)
@@ -231,8 +231,14 @@ class ManagerTest extends TestCase {
                if ($isGroup) {
                        $this->manager->expects($this->never())->method('tryOCMEndPoint');
                } else {
-                       $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', '2342', 'accept')->willReturn(false);
-                       $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', '2342', 'decline')->willReturn(false);
+                       $this->manager->expects($this->any())->method('tryOCMEndPoint')
+                               ->withConsecutive(
+                                       ['http://localhost', 'token1', '2342', 'accept'],
+                                       ['http://localhost', 'token3', '2342', 'decline'],
+                               )->willReturnOnConsecutiveCalls(
+                                       false,
+                                       false,
+                               );
                }
 
                // Add a share for "user"
@@ -375,12 +381,12 @@ class ManagerTest extends TestCase {
                                ->disableOriginalConstructor()->getMock();
                        $client2 = $this->getMockBuilder('OCP\Http\Client\IClient')
                                ->disableOriginalConstructor()->getMock();
-                       $this->clientService->expects($this->at(0))
-                               ->method('newClient')
-                               ->willReturn($client1);
-                       $this->clientService->expects($this->at(1))
+                       $this->clientService->expects($this->exactly(2))
                                ->method('newClient')
-                               ->willReturn($client2);
+                               ->willReturnOnConsecutiveCalls(
+                                       $client1,
+                                       $client2,
+                               );
                        $response = $this->createMock(IResponse::class);
                        $response->method('getBody')
                                ->willReturn(json_encode([
@@ -656,7 +662,7 @@ class ManagerTest extends TestCase {
                $user2Shares = $manager2->getOpenShares();
                $this->assertCount(2, $user2Shares);
 
-               $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', '2342', 'decline')->willReturn([]);
+               $this->manager->expects($this->once())->method('tryOCMEndPoint')->with('http://localhost', 'token1', '2342', 'decline')->willReturn([]);
                $this->manager->removeUserShares($this->uid);
 
                $user1Shares = $this->manager->getOpenShares();
index 00ae847eaac85901a1ab65a7aecae7eefd8b9888..53bea929defa8de115d7613bd620c0dd1db6da43 100644 (file)
@@ -141,26 +141,21 @@ class MountProviderTest extends \Test\TestCase {
                $this->user->expects($this->any())
                        ->method('getUID')
                        ->willReturn('user1');
-               $this->shareManager->expects($this->at(0))
+               $this->shareManager->expects($this->exactly(5))
                        ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_USER)
-                       ->willReturn($userShares);
-               $this->shareManager->expects($this->at(1))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_GROUP, null, -1)
-                       ->willReturn($groupShares);
-               $this->shareManager->expects($this->at(2))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_CIRCLE, null, -1)
-                       ->willReturn($circleShares);
-               $this->shareManager->expects($this->at(3))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_ROOM, null, -1)
-                       ->willReturn($roomShares);
-               $this->shareManager->expects($this->at(4))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_DECK, null, -1)
-                       ->willReturn($deckShares);
+                       ->withConsecutive(
+                               ['user1', IShare::TYPE_USER],
+                               ['user1', IShare::TYPE_GROUP, null, -1],
+                               ['user1', IShare::TYPE_CIRCLE, null, -1],
+                               ['user1', IShare::TYPE_ROOM, null, -1],
+                               ['user1', IShare::TYPE_DECK, null, -1],
+                       )->willReturnOnConsecutiveCalls(
+                               $userShares,
+                               $groupShares,
+                               $circleShares,
+                               $roomShares,
+                               $deckShares,
+                       );
                $this->shareManager->expects($this->any())
                        ->method('newShare')
                        ->willReturnCallback(function () use ($rootFolder, $userManager) {
@@ -362,26 +357,21 @@ class MountProviderTest extends \Test\TestCase {
                $circleShares = [];
                $roomShares = [];
                $deckShares = [];
-               $this->shareManager->expects($this->at(0))
+               $this->shareManager->expects($this->exactly(5))
                        ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_USER)
-                       ->willReturn($userShares);
-               $this->shareManager->expects($this->at(1))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_GROUP, null, -1)
-                       ->willReturn($groupShares);
-               $this->shareManager->expects($this->at(2))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_CIRCLE, null, -1)
-                       ->willReturn($circleShares);
-               $this->shareManager->expects($this->at(3))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_ROOM, null, -1)
-                       ->willReturn($roomShares);
-               $this->shareManager->expects($this->at(4))
-                       ->method('getSharedWith')
-                       ->with('user1', IShare::TYPE_DECK, null, -1)
-                       ->willReturn($deckShares);
+                       ->withConsecutive(
+                               ['user1', IShare::TYPE_USER],
+                               ['user1', IShare::TYPE_GROUP, null, -1],
+                               ['user1', IShare::TYPE_CIRCLE, null, -1],
+                               ['user1', IShare::TYPE_ROOM, null, -1],
+                               ['user1', IShare::TYPE_DECK, null, -1],
+                       )->willReturnOnConsecutiveCalls(
+                               $userShares,
+                               $groupShares,
+                               $circleShares,
+                               $roomShares,
+                               $deckShares,
+                       );
                $this->shareManager->expects($this->any())
                        ->method('newShare')
                        ->willReturnCallback(function () use ($rootFolder, $userManager) {