Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2018-04-06 16:14:12 +0300
committerGitHub <noreply@github.com>2018-04-06 16:14:12 +0300
commitd45a889fe22273aab64e8a339b57da097988cd36 (patch)
treea623b126b677f04fffd4b06bc2efef740743636f /tests
parentb9ca1216712f9eff0471ac58d49b8ee8391a5d28 (diff)
parent5e15c76d214d6d1425bf05ceaa937371e71eaa38 (diff)
Merge pull request #8779 from nextcloud/backport/8255/show-group-display-names
[stable13] Show group display names
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/GroupsControllerTest.php56
-rw-r--r--tests/lib/Group/MetaDataTest.php19
2 files changed, 56 insertions, 19 deletions
diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php
index ecbfa9ea05e..43853d81fcf 100644
--- a/tests/Settings/Controller/GroupsControllerTest.php
+++ b/tests/Settings/Controller/GroupsControllerTest.php
@@ -16,6 +16,7 @@ use OC\Settings\Controller\GroupsController;
use OC\User\User;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
@@ -67,6 +68,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('firstGroup'));
$firstGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('1st group'));
+ $firstGroup
->method('count')
->will($this->returnValue(12));
$secondGroup = $this->getMockBuilder(Group::class)
@@ -75,6 +79,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('secondGroup'));
$secondGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('2nd group'));
+ $secondGroup
->method('count')
->will($this->returnValue(25));
$thirdGroup = $this->getMockBuilder(Group::class)
@@ -83,6 +90,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('thirdGroup'));
$thirdGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('3rd group'));
+ $thirdGroup
->method('count')
->will($this->returnValue(14));
$fourthGroup = $this->getMockBuilder(Group::class)
@@ -91,6 +101,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('admin'));
$fourthGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Administrators'));
+ $fourthGroup
->method('count')
->will($this->returnValue(18));
/** @var \OC\Group\Group[] $groups */
@@ -119,7 +132,7 @@ class GroupsControllerTest extends \Test\TestCase {
'adminGroups' => array(
0 => array(
'id' => 'admin',
- 'name' => 'admin',
+ 'name' => 'Administrators',
'usercount' => 0,//User count disabled 18,
)
),
@@ -127,17 +140,17 @@ class GroupsControllerTest extends \Test\TestCase {
array(
0 => array(
'id' => 'firstGroup',
- 'name' => 'firstGroup',
+ 'name' => '1st group',
'usercount' => 0,//User count disabled 12,
),
1 => array(
'id' => 'secondGroup',
- 'name' => 'secondGroup',
+ 'name' => '2nd group',
'usercount' => 0,//User count disabled 25,
),
2 => array(
'id' => 'thirdGroup',
- 'name' => 'thirdGroup',
+ 'name' => '3rd group',
'usercount' => 0,//User count disabled 14,
),
)
@@ -159,6 +172,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('firstGroup'));
$firstGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('1st group'));
+ $firstGroup
->method('count')
->will($this->returnValue(12));
$secondGroup = $this->getMockBuilder(Group::class)
@@ -167,6 +183,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('secondGroup'));
$secondGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('2nd group'));
+ $secondGroup
->method('count')
->will($this->returnValue(25));
$thirdGroup = $this->getMockBuilder(Group::class)
@@ -175,6 +194,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('thirdGroup'));
$thirdGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('3rd group'));
+ $thirdGroup
->method('count')
->will($this->returnValue(14));
$fourthGroup = $this->getMockBuilder(Group::class)
@@ -183,6 +205,9 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getGID')
->will($this->returnValue('admin'));
$fourthGroup
+ ->method('getDisplayName')
+ ->will($this->returnValue('Administrators'));
+ $fourthGroup
->method('count')
->will($this->returnValue(18));
/** @var \OC\Group\Group[] $groups */
@@ -212,7 +237,7 @@ class GroupsControllerTest extends \Test\TestCase {
'adminGroups' => array(
0 => array(
'id' => 'admin',
- 'name' => 'admin',
+ 'name' => 'Administrators',
'usercount' => 18,
)
),
@@ -220,17 +245,17 @@ class GroupsControllerTest extends \Test\TestCase {
array(
0 => array(
'id' => 'secondGroup',
- 'name' => 'secondGroup',
+ 'name' => '2nd group',
'usercount' => 25,
),
1 => array(
'id' => 'thirdGroup',
- 'name' => 'thirdGroup',
+ 'name' => '3rd group',
'usercount' => 14,
),
2 => array(
'id' => 'firstGroup',
- 'name' => 'firstGroup',
+ 'name' => '1st group',
'usercount' => 12,
),
)
@@ -264,15 +289,19 @@ class GroupsControllerTest extends \Test\TestCase {
->method('groupExists')
->with('NewGroup')
->will($this->returnValue(false));
+
+ $group = $this->createMock(IGroup::class);
+ $group->method('getDisplayName')
+ ->willReturn('New group');
$this->groupManager
->expects($this->once())
->method('createGroup')
->with('NewGroup')
- ->will($this->returnValue(true));
+ ->willReturn($group);
$expectedResponse = new DataResponse(
array(
- 'groupname' => 'NewGroup'
+ 'groupname' => 'New group'
),
Http::STATUS_CREATED
);
@@ -304,13 +333,14 @@ class GroupsControllerTest extends \Test\TestCase {
}
public function testDestroySuccessful() {
- $group = $this->getMockBuilder(Group::class)
- ->disableOriginalConstructor()->getMock();
+ $group = $this->createMock(IGroup::class);
$this->groupManager
->expects($this->once())
->method('get')
->with('ExistingGroup')
->will($this->returnValue($group));
+ $group->method('getDisplayName')
+ ->willReturn('Existing group');
$group
->expects($this->once())
->method('delete')
@@ -319,7 +349,7 @@ class GroupsControllerTest extends \Test\TestCase {
$expectedResponse = new DataResponse(
array(
'status' => 'success',
- 'data' => array('groupname' => 'ExistingGroup')
+ 'data' => array('groupname' => 'Existing group')
),
Http::STATUS_NO_CONTENT
);
diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php
index 04d2ff807b4..4e6389aad6b 100644
--- a/tests/lib/Group/MetaDataTest.php
+++ b/tests/lib/Group/MetaDataTest.php
@@ -53,12 +53,19 @@ class MetaDataTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $group->expects($this->exactly(9))
+ $group->expects($this->exactly(6))
->method('getGID')
->will($this->onConsecutiveCalls(
- 'admin', 'admin', 'admin',
- 'g2', 'g2', 'g2',
- 'g3', 'g3', 'g3'));
+ 'admin', 'admin',
+ 'g2', 'g2',
+ 'g3', 'g3'));
+
+ $group->expects($this->exactly(3))
+ ->method('getDisplayName')
+ ->will($this->onConsecutiveCalls(
+ 'display admin',
+ 'display g2',
+ 'display g3'));
$group->expects($this->exactly($countCallCount))
->method('count')
@@ -83,7 +90,7 @@ class MetaDataTest extends \Test\TestCase {
$this->assertSame(1, count($adminGroups));
$this->assertSame(2, count($ordinaryGroups));
- $this->assertSame('g2', $ordinaryGroups[0]['name']);
+ $this->assertSame('display g2', $ordinaryGroups[0]['name']);
// user count is not loaded
$this->assertSame(0, $ordinaryGroups[0]['usercount']);
}
@@ -103,7 +110,7 @@ class MetaDataTest extends \Test\TestCase {
$this->assertSame(1, count($adminGroups));
$this->assertSame(2, count($ordinaryGroups));
- $this->assertSame('g3', $ordinaryGroups[0]['name']);
+ $this->assertSame('display g3', $ordinaryGroups[0]['name']);
$this->assertSame(5, $ordinaryGroups[0]['usercount']);
}