aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Group
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Group')
-rw-r--r--tests/Core/Command/Group/AddTest.php27
-rw-r--r--tests/Core/Command/Group/AddUserTest.php29
-rw-r--r--tests/Core/Command/Group/DeleteTest.php31
-rw-r--r--tests/Core/Command/Group/InfoTest.php29
-rw-r--r--tests/Core/Command/Group/ListCommandTest.php95
-rw-r--r--tests/Core/Command/Group/RemoveUserTest.php29
6 files changed, 74 insertions, 166 deletions
diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php
index 65806fa538b..24f2d823292 100644
--- a/tests/Core/Command/Group/AddTest.php
+++ b/tests/Core/Command/Group/AddTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
- *
- * @author Denis Mosolov <denismosolov@gmail.com>
- *
- * @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 Afferoq 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: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
@@ -31,7 +15,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class AddTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -61,7 +44,7 @@ class AddTest extends TestCase {
$this->output = $this->createMock(OutputInterface::class);
}
- public function testGroupExists() {
+ public function testGroupExists(): void {
$gid = 'myGroup';
$group = $this->createMock(IGroup::class);
$this->groupManager->method('get')
@@ -77,7 +60,7 @@ class AddTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testAdd() {
+ public function testAdd(): void {
$gid = 'myGroup';
$group = $this->createMock(IGroup::class);
$group->method('getGID')
diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php
index d9471956dfd..68c8cecdba1 100644
--- a/tests/Core/Command/Group/AddUserTest.php
+++ b/tests/Core/Command/Group/AddUserTest.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;
@@ -33,7 +17,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class AddUserTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -69,7 +52,7 @@ class AddUserTest extends TestCase {
$this->output = $this->createMock(OutputInterface::class);
}
- public function testNoGroup() {
+ public function testNoGroup(): void {
$this->groupManager->method('get')
->with('myGroup')
->willReturn(null);
@@ -81,7 +64,7 @@ class AddUserTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testNoUser() {
+ public function testNoUser(): void {
$group = $this->createMock(IGroup::class);
$this->groupManager->method('get')
->with('myGroup')
@@ -98,7 +81,7 @@ class AddUserTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testAdd() {
+ public function testAdd(): void {
$group = $this->createMock(IGroup::class);
$this->groupManager->method('get')
->with('myGroup')
diff --git a/tests/Core/Command/Group/DeleteTest.php b/tests/Core/Command/Group/DeleteTest.php
index 3b29fb4e6ad..289c6a7c322 100644
--- a/tests/Core/Command/Group/DeleteTest.php
+++ b/tests/Core/Command/Group/DeleteTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
- *
- * @author Denis Mosolov <denismosolov@gmail.com>
- *
- * @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 Afferoq 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: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
@@ -31,7 +15,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class DeleteTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -54,7 +37,7 @@ class DeleteTest extends TestCase {
$this->output = $this->createMock(OutputInterface::class);
}
- public function testDoesNotExists() {
+ public function testDoesNotExists(): void {
$gid = 'myGroup';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
@@ -76,7 +59,7 @@ class DeleteTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testDeleteAdmin() {
+ public function testDeleteAdmin(): void {
$gid = 'admin';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
@@ -95,7 +78,7 @@ class DeleteTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testDeleteFailed() {
+ public function testDeleteFailed(): void {
$gid = 'myGroup';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
@@ -121,7 +104,7 @@ class DeleteTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testDelete() {
+ public function testDelete(): void {
$gid = 'myGroup';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
diff --git a/tests/Core/Command/Group/InfoTest.php b/tests/Core/Command/Group/InfoTest.php
index fc98cf647c7..87f59d2adc4 100644
--- a/tests/Core/Command/Group/InfoTest.php
+++ b/tests/Core/Command/Group/InfoTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @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 Afferoq 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: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
@@ -31,7 +15,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class InfoTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -50,14 +33,14 @@ class InfoTest extends TestCase {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->command = $this->getMockBuilder(Info::class)
->setConstructorArgs([$this->groupManager])
- ->setMethods(['writeArrayInOutputFormat'])
+ ->onlyMethods(['writeArrayInOutputFormat'])
->getMock();
$this->input = $this->createMock(InputInterface::class);
$this->output = $this->createMock(OutputInterface::class);
}
- public function testDoesNotExists() {
+ public function testDoesNotExists(): void {
$gid = 'myGroup';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
@@ -77,7 +60,7 @@ class InfoTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testInfo() {
+ public function testInfo(): void {
$gid = 'myGroup';
$this->input->method('getArgument')
->willReturnCallback(function ($arg) use ($gid) {
diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php
index ed454a796a6..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;
@@ -32,7 +16,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class ListCommandTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -51,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);
@@ -108,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);
@@ -184,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]);
diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php
index 495046402a8..74343e77d3f 100644
--- a/tests/Core/Command/Group/RemoveUserTest.php
+++ b/tests/Core/Command/Group/RemoveUserTest.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;
@@ -33,7 +17,6 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class RemoveUserTest extends TestCase {
-
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
private $groupManager;
@@ -69,7 +52,7 @@ class RemoveUserTest extends TestCase {
$this->output = $this->createMock(OutputInterface::class);
}
- public function testNoGroup() {
+ public function testNoGroup(): void {
$this->groupManager->method('get')
->with('myGroup')
->willReturn(null);
@@ -81,7 +64,7 @@ class RemoveUserTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testNoUser() {
+ public function testNoUser(): void {
$group = $this->createMock(IGroup::class);
$this->groupManager->method('get')
->with('myGroup')
@@ -98,7 +81,7 @@ class RemoveUserTest extends TestCase {
$this->invokePrivate($this->command, 'execute', [$this->input, $this->output]);
}
- public function testAdd() {
+ public function testAdd(): void {
$group = $this->createMock(IGroup::class);
$this->groupManager->method('get')
->with('myGroup')