summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php204
1 files changed, 102 insertions, 102 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
index 99d8ea72bb0..57613c19f64 100644
--- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
@@ -100,29 +100,29 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$fooUser
->expects($this->exactly(1))
->method('getDisplayName')
- ->will($this->returnValue('Dr. Foo-Bar'));
+ ->willReturn('Dr. Foo-Bar');
$fooUser
->expects($this->exactly(1))
->method('getEMailAddress')
- ->will($this->returnValue(''));
+ ->willReturn('');
$barUser = $this->createMock(User::class);
$barUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('bar'));
+ ->willReturn('bar');
$barUser
->expects($this->exactly(1))
->method('getEMailAddress')
- ->will($this->returnValue('bar@nextcloud.com'));
+ ->willReturn('bar@nextcloud.com');
$this->userManager
->expects($this->once())
->method('search')
->with('')
- ->will($this->returnValue([$fooUser, $barUser]));
+ ->willReturn([$fooUser, $barUser]);
$expectedResponse = [
0 => [
@@ -146,7 +146,7 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('search')
->with('')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$response = $this->connector->getPrincipalsByPrefix('principals/users');
$this->assertSame([], $response);
@@ -157,12 +157,12 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$expectedResponse = [
'uri' => 'principals/users/foo',
@@ -178,16 +178,16 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getEMailAddress')
- ->will($this->returnValue('foo@nextcloud.com'));
+ ->willReturn('foo@nextcloud.com');
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$expectedResponse = [
'uri' => 'principals/users/foo',
@@ -204,7 +204,7 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$response = $this->connector->getPrincipalByPath('principals/users/foo');
$this->assertSame(null, $response);
@@ -224,7 +224,7 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$this->connector->getGroupMemberSet('principals/users/foo/calendar-proxy-read');
}
@@ -234,12 +234,12 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$proxy1 = new Proxy();
$proxy1->setProxyId('proxyId1');
@@ -266,12 +266,12 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$this->userManager
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$proxy1 = new Proxy();
$proxy1->setProxyId('proxyId1');
@@ -349,7 +349,7 @@ class PrincipalTest extends TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$this->connector->getGroupMembership('principals/users/foo');
}
@@ -367,22 +367,22 @@ class PrincipalTest extends TestCase {
$fooUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$barUser = $this->createMock(User::class);
$barUser
->expects($this->exactly(1))
->method('getUID')
- ->will($this->returnValue('bar'));
+ ->willReturn('bar');
$this->userManager
->expects($this->at(0))
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$this->userManager
->expects($this->at(1))
->method('get')
->with('bar')
- ->will($this->returnValue($barUser));
+ ->willReturn($barUser);
$this->proxyMapper->expects($this->at(0))
->method('getProxiesOf')
@@ -428,7 +428,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipals($sharingEnabled, $groupsOnly, $test, $result) {
$this->shareManager->expects($this->once())
->method('shareAPIEnabled')
- ->will($this->returnValue($sharingEnabled));
+ ->willReturn($sharingEnabled);
if ($sharingEnabled) {
$this->shareManager->expects($this->once())
@@ -437,18 +437,18 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue($groupsOnly));
+ ->willReturn($groupsOnly);
if ($groupsOnly) {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->groupManager->expects($this->at(0))
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(['group1', 'group2', 'group5']));
+ ->willReturn(['group1', 'group2', 'group5']);
}
} else {
$this->config->expects($this->never())
@@ -460,22 +460,22 @@ class PrincipalTest extends TestCase {
}
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
+ $user2->method('getUID')->willReturn('user2');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
+ $user3->method('getUID')->willReturn('user3');
$user4 = $this->createMock(IUser::class);
- $user4->method('getUID')->will($this->returnValue('user4'));
+ $user4->method('getUID')->willReturn('user4');
if ($sharingEnabled) {
$this->userManager->expects($this->at(0))
->method('getByEmail')
->with('user@example.com')
- ->will($this->returnValue([$user2, $user3]));
+ ->willReturn([$user2, $user3]);
$this->userManager->expects($this->at(1))
->method('searchDisplayName')
->with('User 12')
- ->will($this->returnValue([$user3, $user4]));
+ ->willReturn([$user3, $user4]);
} else {
$this->userManager->expects($this->never())
->method('getByEmail');
@@ -488,19 +488,19 @@ class PrincipalTest extends TestCase {
$this->groupManager->expects($this->at(1))
->method('getUserGroupIds')
->with($user2)
- ->will($this->returnValue(['group1', 'group3']));
+ ->willReturn(['group1', 'group3']);
$this->groupManager->expects($this->at(2))
->method('getUserGroupIds')
->with($user3)
- ->will($this->returnValue(['group3', 'group4']));
+ ->willReturn(['group3', 'group4']);
$this->groupManager->expects($this->at(3))
->method('getUserGroupIds')
->with($user3)
- ->will($this->returnValue(['group3', 'group4']));
+ ->willReturn(['group3', 'group4']);
$this->groupManager->expects($this->at(4))
->method('getUserGroupIds')
->with($user4)
- ->will($this->returnValue(['group4', 'group5']));
+ ->willReturn(['group4', 'group5']);
}
@@ -523,7 +523,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipalByCalendarUserAddressSet() {
$this->shareManager->expects($this->exactly(2))
->method('shareAPIEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->exactly(2))
->method('allowEnumeration')
@@ -531,17 +531,17 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->exactly(2))
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
+ $user2->method('getUID')->willReturn('user2');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
+ $user3->method('getUID')->willReturn('user3');
$this->userManager->expects($this->at(0))
->method('getByEmail')
->with('user@example.com')
- ->will($this->returnValue([$user2, $user3]));
+ ->willReturn([$user2, $user3]);
$this->assertEquals([
'principals/users/user2',
@@ -553,7 +553,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipalWithEnumerationDisabledDisplayname() {
$this->shareManager->expects($this->once())
->method('shareAPIEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->once())
->method('allowEnumeration')
@@ -561,25 +561,25 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
- $user2->method('getDisplayName')->will($this->returnValue('User 2'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar'));
+ $user2->method('getUID')->willReturn('user2');
+ $user2->method('getDisplayName')->willReturn('User 2');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
- $user2->method('getDisplayName')->will($this->returnValue('User 22'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar123'));
+ $user3->method('getUID')->willReturn('user3');
+ $user2->method('getDisplayName')->willReturn('User 22');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar123');
$user4 = $this->createMock(IUser::class);
- $user4->method('getUID')->will($this->returnValue('user4'));
- $user2->method('getDisplayName')->will($this->returnValue('User 222'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar456'));
+ $user4->method('getUID')->willReturn('user4');
+ $user2->method('getDisplayName')->willReturn('User 222');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar456');
$this->userManager->expects($this->at(0))
->method('searchDisplayName')
->with('User 2')
- ->will($this->returnValue([$user2, $user3, $user4]));
+ ->willReturn([$user2, $user3, $user4]);
$this->assertEquals(['principals/users/user2'], $this->connector->searchPrincipals('principals/users',
['{DAV:}displayname' => 'User 2']));
@@ -588,7 +588,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipalWithEnumerationDisabledEmail() {
$this->shareManager->expects($this->once())
->method('shareAPIEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->once())
->method('allowEnumeration')
@@ -596,25 +596,25 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
- $user2->method('getDisplayName')->will($this->returnValue('User 2'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar'));
+ $user2->method('getUID')->willReturn('user2');
+ $user2->method('getDisplayName')->willReturn('User 2');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
- $user2->method('getDisplayName')->will($this->returnValue('User 22'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar123'));
+ $user3->method('getUID')->willReturn('user3');
+ $user2->method('getDisplayName')->willReturn('User 22');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar123');
$user4 = $this->createMock(IUser::class);
- $user4->method('getUID')->will($this->returnValue('user4'));
- $user2->method('getDisplayName')->will($this->returnValue('User 222'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar456'));
+ $user4->method('getUID')->willReturn('user4');
+ $user2->method('getDisplayName')->willReturn('User 222');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar456');
$this->userManager->expects($this->at(0))
->method('getByEmail')
->with('user2@foo.bar')
- ->will($this->returnValue([$user2, $user3, $user4]));
+ ->willReturn([$user2, $user3, $user4]);
$this->assertEquals(['principals/users/user2'], $this->connector->searchPrincipals('principals/users',
['{http://sabredav.org/ns}email-address' => 'user2@foo.bar']));
@@ -623,7 +623,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipalWithEnumerationLimitedDisplayname() {
$this->shareManager->expects($this->at(0))
->method('shareAPIEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->at(1))
->method('allowEnumeration')
@@ -635,20 +635,20 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
- $user2->method('getDisplayName')->will($this->returnValue('User 2'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar'));
+ $user2->method('getUID')->willReturn('user2');
+ $user2->method('getDisplayName')->willReturn('User 2');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
- $user3->method('getDisplayName')->will($this->returnValue('User 22'));
- $user3->method('getEMailAddress')->will($this->returnValue('user2@foo.bar123'));
+ $user3->method('getUID')->willReturn('user3');
+ $user3->method('getDisplayName')->willReturn('User 22');
+ $user3->method('getEMailAddress')->willReturn('user2@foo.bar123');
$user4 = $this->createMock(IUser::class);
- $user4->method('getUID')->will($this->returnValue('user4'));
- $user4->method('getDisplayName')->will($this->returnValue('User 222'));
- $user4->method('getEMailAddress')->will($this->returnValue('user2@foo.bar456'));
+ $user4->method('getUID')->willReturn('user4');
+ $user4->method('getDisplayName')->willReturn('User 222');
+ $user4->method('getEMailAddress')->willReturn('user2@foo.bar456');
$this->userSession->expects($this->at(0))
@@ -684,7 +684,7 @@ class PrincipalTest extends TestCase {
public function testSearchPrincipalWithEnumerationLimitedMail() {
$this->shareManager->expects($this->at(0))
->method('shareAPIEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->at(1))
->method('allowEnumeration')
@@ -696,20 +696,20 @@ class PrincipalTest extends TestCase {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
- $user2->method('getDisplayName')->will($this->returnValue('User 2'));
- $user2->method('getEMailAddress')->will($this->returnValue('user2@foo.bar'));
+ $user2->method('getUID')->willReturn('user2');
+ $user2->method('getDisplayName')->willReturn('User 2');
+ $user2->method('getEMailAddress')->willReturn('user2@foo.bar');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
- $user3->method('getDisplayName')->will($this->returnValue('User 22'));
- $user3->method('getEMailAddress')->will($this->returnValue('user2@foo.bar123'));
+ $user3->method('getUID')->willReturn('user3');
+ $user3->method('getDisplayName')->willReturn('User 22');
+ $user3->method('getEMailAddress')->willReturn('user2@foo.bar123');
$user4 = $this->createMock(IUser::class);
- $user4->method('getUID')->will($this->returnValue('user4'));
- $user4->method('getDisplayName')->will($this->returnValue('User 222'));
- $user4->method('getEMailAddress')->will($this->returnValue('user2@foo.bar456'));
+ $user4->method('getUID')->willReturn('user4');
+ $user4->method('getDisplayName')->willReturn('User 222');
+ $user4->method('getEMailAddress')->willReturn('user2@foo.bar456');
$this->userSession->expects($this->at(0))
@@ -745,7 +745,7 @@ class PrincipalTest extends TestCase {
public function testFindByUriSharingApiDisabled() {
$this->shareManager->expects($this->once())
->method('shareApiEnabled')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertEquals(null, $this->connector->findByUri('mailto:user@foo.com', 'principals/users'));
}
@@ -756,42 +756,42 @@ class PrincipalTest extends TestCase {
public function testFindByUriWithGroupRestriction($uri, $email, $expects) {
$this->shareManager->expects($this->once())
->method('shareApiEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->groupManager->expects($this->at(0))
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(['group1', 'group2']));
+ ->willReturn(['group1', 'group2']);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
+ $user2->method('getUID')->willReturn('user2');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
+ $user3->method('getUID')->willReturn('user3');
$this->userManager->expects($this->once())
->method('getByEmail')
->with($email)
- ->will($this->returnValue([$email === 'user2@foo.bar' ? $user2 : $user3]));
+ ->willReturn([$email === 'user2@foo.bar' ? $user2 : $user3]);
if ($email === 'user2@foo.bar') {
$this->groupManager->expects($this->at(1))
->method('getUserGroupIds')
->with($user2)
- ->will($this->returnValue(['group1', 'group3']));
+ ->willReturn(['group1', 'group3']);
} else {
$this->groupManager->expects($this->at(1))
->method('getUserGroupIds')
->with($user3)
- ->will($this->returnValue(['group3', 'group3']));
+ ->willReturn(['group3', 'group3']);
}
$this->assertEquals($expects, $this->connector->findByUri($uri, 'principals/users'));
@@ -810,21 +810,21 @@ class PrincipalTest extends TestCase {
public function testFindByUriWithoutGroupRestriction($uri, $email, $expects) {
$this->shareManager->expects($this->once())
->method('shareApiEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user2 = $this->createMock(IUser::class);
- $user2->method('getUID')->will($this->returnValue('user2'));
+ $user2->method('getUID')->willReturn('user2');
$user3 = $this->createMock(IUser::class);
- $user3->method('getUID')->will($this->returnValue('user3'));
+ $user3->method('getUID')->willReturn('user3');
$this->userManager->expects($this->once())
->method('getByEmail')
->with($email)
- ->will($this->returnValue([$email === 'user2@foo.bar' ? $user2 : $user3]));
+ ->willReturn([$email === 'user2@foo.bar' ? $user2 : $user3]);
$this->assertEquals($expects, $this->connector->findByUri($uri, 'principals/users'));
}