diff options
Diffstat (limited to 'tests/Core/Command/Group')
-rw-r--r-- | tests/Core/Command/Group/AddTest.php | 26 | ||||
-rw-r--r-- | tests/Core/Command/Group/AddUserTest.php | 28 | ||||
-rw-r--r-- | tests/Core/Command/Group/DeleteTest.php | 30 | ||||
-rw-r--r-- | tests/Core/Command/Group/InfoTest.php | 28 | ||||
-rw-r--r-- | tests/Core/Command/Group/ListCommandTest.php | 94 | ||||
-rw-r--r-- | tests/Core/Command/Group/RemoveUserTest.php | 28 |
6 files changed, 74 insertions, 160 deletions
diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php index bfddee468a4..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; @@ -60,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') @@ -76,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 c885365f8c6..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; @@ -68,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); @@ -80,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') @@ -97,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 393f33aea98..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; @@ -53,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) { @@ -75,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) { @@ -94,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) { @@ -120,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 3f1cc359799..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; @@ -49,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) { @@ -76,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 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]); diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php index 470d5965333..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; @@ -68,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); @@ -80,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') @@ -97,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') |