aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Command/MoveCalendarTest.php
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-01-05 18:25:31 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-01-05 18:28:07 +0100
commit574c6770d18f74c26ec3b72075a52333e6495a7a (patch)
tree28f0c760c0664062c2fb34becdaab7b36fea48c2 /apps/dav/tests/unit/Command/MoveCalendarTest.php
parentadef2b85c8c8f771d694dedec2c8509694aee149 (diff)
downloadnextcloud-server-574c6770d18f74c26ec3b72075a52333e6495a7a.tar.gz
nextcloud-server-574c6770d18f74c26ec3b72075a52333e6495a7a.zip
Get rid of deprecated at matcher in dav application tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/dav/tests/unit/Command/MoveCalendarTest.php')
-rw-r--r--apps/dav/tests/unit/Command/MoveCalendarTest.php235
1 files changed, 116 insertions, 119 deletions
diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php
index 5a858e140ac..3dbc56db359 100644
--- a/apps/dav/tests/unit/Command/MoveCalendarTest.php
+++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php
@@ -45,7 +45,6 @@ use Test\TestCase;
* @package OCA\DAV\Tests\Command
*/
class MoveCalendarTest extends TestCase {
-
/** @var \OCP\IUserManager|MockObject $userManager */
private $userManager;
@@ -108,17 +107,16 @@ class MoveCalendarTest extends TestCase {
public function testWithBadUserOrigin($userOriginExists, $userDestinationExists) {
$this->expectException(\InvalidArgumentException::class);
- $this->userManager->expects($this->at(0))
+ $this->userManager->expects($this->exactly($userOriginExists ? 2 : 1))
->method('userExists')
- ->with('user')
- ->willReturn($userOriginExists);
-
- if (!$userDestinationExists) {
- $this->userManager->expects($this->at(1))
- ->method('userExists')
- ->with('user2')
- ->willReturn($userDestinationExists);
- }
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $userOriginExists,
+ $userDestinationExists,
+ );
$commandTester = new CommandTester($this->command);
$commandTester->execute([
@@ -133,14 +131,12 @@ class MoveCalendarTest extends TestCase {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.');
- $this->userManager->expects($this->at(0))
- ->method('userExists')
- ->with('user')
- ->willReturn(true);
-
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user2')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
$this->calDav->expects($this->once())->method('getCalendarByUri')
@@ -160,24 +156,20 @@ class MoveCalendarTest extends TestCase {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('User <user2> already has a calendar named <personal>.');
- $this->userManager->expects($this->at(0))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->userManager->expects($this->at(1))
- ->method('userExists')
- ->with('user2')
- ->willReturn(true);
-
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
->willReturn([
'id' => 1234,
]);
@@ -191,25 +183,26 @@ class MoveCalendarTest extends TestCase {
}
public function testMove() {
- $this->userManager->expects($this->at(0))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->userManager->expects($this->at(1))
- ->method('userExists')
- ->with('user2')
- ->willReturn(true);
-
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
- ->willReturn(null);
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ [
+ 'id' => 1234,
+ ],
+ null,
+ );
$this->calDav->expects($this->once())->method('getShares')
->with(1234)
@@ -236,26 +229,27 @@ class MoveCalendarTest extends TestCase {
* @dataProvider dataTestMoveWithDestinationNotPartOfGroup
*/
public function testMoveWithDestinationNotPartOfGroup(bool $shareWithGroupMembersOnly) {
- $this->userManager->expects($this->at(0))
- ->method('userExists')
- ->with('user')
- ->willReturn(true);
-
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user2')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- 'uri' => 'personal'
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
- ->willReturn(null);
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ [
+ 'id' => 1234,
+ 'uri' => 'personal',
+ ],
+ null,
+ );
$this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
->willReturn($shareWithGroupMembersOnly);
@@ -279,26 +273,27 @@ class MoveCalendarTest extends TestCase {
}
public function testMoveWithDestinationPartOfGroup() {
- $this->userManager->expects($this->at(0))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->userManager->expects($this->at(1))
- ->method('userExists')
- ->with('user2')
- ->willReturn(true);
-
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- 'uri' => 'personal'
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
- ->willReturn(null);
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ [
+ 'id' => 1234,
+ 'uri' => 'personal',
+ ],
+ null,
+ );
$this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
->willReturn(true);
@@ -324,27 +319,28 @@ class MoveCalendarTest extends TestCase {
}
public function testMoveWithDestinationNotPartOfGroupAndForce() {
- $this->userManager->expects($this->at(0))
- ->method('userExists')
- ->with('user')
- ->willReturn(true);
-
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user2')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- 'uri' => 'personal',
- '{DAV:}displayname' => 'Personal'
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
- ->willReturn(null);
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ [
+ 'id' => 1234,
+ 'uri' => 'personal',
+ '{DAV:}displayname' => 'Personal'
+ ],
+ null,
+ );
$this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
->willReturn(true);
@@ -381,27 +377,28 @@ class MoveCalendarTest extends TestCase {
* @dataProvider dataTestMoveWithCalendarAlreadySharedToDestination
*/
public function testMoveWithCalendarAlreadySharedToDestination(bool $force) {
- $this->userManager->expects($this->at(0))
- ->method('userExists')
- ->with('user')
- ->willReturn(true);
-
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('userExists')
- ->with('user2')
+ ->withConsecutive(
+ ['user'],
+ ['user2'],
+ )
->willReturn(true);
- $this->calDav->expects($this->at(0))->method('getCalendarByUri')
- ->with('principals/users/user', 'personal')
- ->willReturn([
- 'id' => 1234,
- 'uri' => 'personal',
- '{DAV:}displayname' => 'Personal',
- ]);
-
- $this->calDav->expects($this->at(1))->method('getCalendarByUri')
- ->with('principals/users/user2', 'personal')
- ->willReturn(null);
+ $this->calDav->expects($this->exactly(2))
+ ->method('getCalendarByUri')
+ ->withConsecutive(
+ ['principals/users/user', 'personal'],
+ ['principals/users/user2', 'personal'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ [
+ 'id' => 1234,
+ 'uri' => 'personal',
+ '{DAV:}displayname' => 'Personal'
+ ],
+ null,
+ );
$this->calDav->expects($this->once())->method('getShares')
->with(1234)