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.php45
1 files changed, 22 insertions, 23 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
index 03856807026..8d7485769fa 100644
--- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
@@ -25,6 +25,8 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre;
+use OC\User\User;
+use OCP\IGroup;
use OCP\IGroupManager;
use \Sabre\DAV\PropPatch;
use OCP\IUserManager;
@@ -39,10 +41,8 @@ class PrincipalTest extends TestCase {
private $groupManager;
public function setUp() {
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')
- ->disableOriginalConstructor()->getMock();
- $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')
- ->disableOriginalConstructor()->getMock();
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
$this->connector = new \OCA\DAV\Connector\Sabre\Principal(
$this->userManager,
@@ -56,8 +56,7 @@ class PrincipalTest extends TestCase {
}
public function testGetPrincipalsByPrefixWithUsers() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $fooUser = $this->createMock(User::class);
$fooUser
->expects($this->exactly(1))
->method('getUID')
@@ -70,8 +69,7 @@ class PrincipalTest extends TestCase {
->expects($this->exactly(1))
->method('getEMailAddress')
->will($this->returnValue(''));
- $barUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $barUser = $this->createMock(User::class);
$barUser
->expects($this->exactly(1))
->method('getUID')
@@ -113,8 +111,7 @@ class PrincipalTest extends TestCase {
}
public function testGetPrincipalsByPathWithoutMail() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $fooUser = $this->createMock(User::class);
$fooUser
->expects($this->exactly(1))
->method('getUID')
@@ -134,8 +131,7 @@ class PrincipalTest extends TestCase {
}
public function testGetPrincipalsByPathWithMail() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $fooUser = $this->createMock(User::class);
$fooUser
->expects($this->exactly(1))
->method('getEMailAddress')
@@ -171,8 +167,7 @@ class PrincipalTest extends TestCase {
}
public function testGetGroupMemberSet() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $fooUser = $this->createMock(User::class);
$fooUser
->expects($this->exactly(1))
->method('getUID')
@@ -202,13 +197,15 @@ class PrincipalTest extends TestCase {
}
public function testGetGroupMembership() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
- $group = $this->getMockBuilder('\OCP\IGroup')
- ->disableOriginalConstructor()->getMock();
- $group->expects($this->once())
+ $fooUser = $this->createMock(User::class);
+ $group1 = $this->createMock(IGroup::class);
+ $group1->expects($this->once())
->method('getGID')
->willReturn('group1');
+ $group2 = $this->createMock(IGroup::class);
+ $group2->expects($this->once())
+ ->method('getGID')
+ ->willReturn('foo/bar');
$this->userManager
->expects($this->once())
->method('get')
@@ -217,12 +214,15 @@ class PrincipalTest extends TestCase {
$this->groupManager
->expects($this->once())
->method('getUserGroups')
+ ->with($fooUser)
->willReturn([
- $group
+ $group1,
+ $group2,
]);
$expectedResponse = [
- 'principals/groups/group1'
+ 'principals/groups/group1',
+ 'principals/groups/foo%2Fbar',
];
$response = $this->connector->getGroupMembership('principals/users/foo');
$this->assertSame($expectedResponse, $response);
@@ -259,8 +259,7 @@ class PrincipalTest extends TestCase {
}
public function testFindByUri() {
- $fooUser = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
+ $fooUser = $this->createMock(User::class);
$fooUser
->expects($this->exactly(1))
->method('getUID')