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.php73
1 files changed, 42 insertions, 31 deletions
diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php
index e4e91ce1458..aaca772d714 100644
--- a/tests/Core/Command/Group/ListCommandTest.php
+++ b/tests/Core/Command/Group/ListCommandTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -33,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);
@@ -90,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);
@@ -166,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]);