aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Group/ListCommandTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Group/ListCommandTest.php')
-rw-r--r--tests/Core/Command/Group/ListCommandTest.php94
1 files changed, 44 insertions, 50 deletions
diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php
index f8e750bbe65..aaca772d714 100644
--- a/tests/Core/Command/Group/ListCommandTest.php
+++ b/tests/Core/Command/Group/ListCommandTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
@@ -50,14 +34,14 @@ class ListCommandTest extends TestCase {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->command = $this->getMockBuilder(ListCommand::class)
->setConstructorArgs([$this->groupManager])
- ->setMethods(['writeArrayInOutputFormat'])
+ ->onlyMethods(['writeArrayInOutputFormat'])
->getMock();
$this->input = $this->createMock(InputInterface::class);
$this->output = $this->createMock(OutputInterface::class);
}
- public function testExecute() {
+ public function testExecute(): void {
$group1 = $this->createMock(IGroup::class);
$group1->method('getGID')->willReturn('group1');
$group2 = $this->createMock(IGroup::class);
@@ -107,30 +91,35 @@ class ListCommandTest extends TestCase {
->with(
$this->equalTo($this->input),
$this->equalTo($this->output),
- [
- 'group1' => [
- 'user1',
- 'user2',
- ],
- 'group2' => [
- ],
- 'group3' => [
- 'user1',
- 'user3',
+ $this->callback(
+ fn ($iterator) => iterator_to_array($iterator) === [
+ 'group1' => [
+ 'user1',
+ 'user2',
+ ],
+ 'group2' => [
+ ],
+ 'group3' => [
+ 'user1',
+ 'user3',
+ ]
]
- ]
+ )
);
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testInfo() {
+ public function testInfo(): void {
$group1 = $this->createMock(IGroup::class);
$group1->method('getGID')->willReturn('group1');
+ $group1->method('getDisplayName')->willReturn('Group 1');
$group2 = $this->createMock(IGroup::class);
$group2->method('getGID')->willReturn('group2');
+ $group2->method('getDisplayName')->willReturn('Group 2');
$group3 = $this->createMock(IGroup::class);
$group3->method('getGID')->willReturn('group3');
+ $group3->method('getDisplayName')->willReturn('Group 3');
$user = $this->createMock(IUser::class);
@@ -183,26 +172,31 @@ class ListCommandTest extends TestCase {
->with(
$this->equalTo($this->input),
$this->equalTo($this->output),
- [
- 'group1' => [
- 'backends' => ['Database'],
- 'users' => [
- 'user1',
- 'user2',
+ $this->callback(
+ fn ($iterator) => iterator_to_array($iterator) === [
+ 'group1' => [
+ 'displayName' => 'Group 1',
+ 'backends' => ['Database'],
+ 'users' => [
+ 'user1',
+ 'user2',
+ ],
],
- ],
- 'group2' => [
- 'backends' => ['Database'],
- 'users' => [],
- ],
- 'group3' => [
- 'backends' => ['LDAP'],
- 'users' => [
- 'user1',
- 'user3',
+ 'group2' => [
+ 'displayName' => 'Group 2',
+ 'backends' => ['Database'],
+ 'users' => [],
],
+ 'group3' => [
+ 'displayName' => 'Group 3',
+ 'backends' => ['LDAP'],
+ 'users' => [
+ 'user1',
+ 'user3',
+ ],
+ ]
]
- ]
+ )
);
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);