diff options
Diffstat (limited to 'apps/user_ldap/tests/Migration/UUIDFixInsertTest.php')
-rw-r--r-- | apps/user_ldap/tests/Migration/UUIDFixInsertTest.php | 83 |
1 files changed, 30 insertions, 53 deletions
diff --git a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php index 6645ccc9431..6215ffcb6a1 100644 --- a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php +++ b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php @@ -1,26 +1,9 @@ <?php + +declare(strict_types=1); /** - * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Morris Jobke <hey@morrisjobke.de> - * @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: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\User_LDAP\Tests\Migration; @@ -30,23 +13,15 @@ use OCA\User_LDAP\Migration\UUIDFixInsert; use OCP\BackgroundJob\IJobList; use OCP\IConfig; use OCP\Migration\IOutput; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class UUIDFixInsertTest extends TestCase { - /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ - protected $config; - - /** @var UserMapping|\PHPUnit\Framework\MockObject\MockObject */ - protected $userMapper; - - /** @var GroupMapping|\PHPUnit\Framework\MockObject\MockObject */ - protected $groupMapper; - - /** @var IJobList|\PHPUnit\Framework\MockObject\MockObject */ - protected $jobList; - - /** @var UUIDFixInsert */ - protected $job; + protected IConfig&MockObject $config; + protected UserMapping&MockObject $userMapper; + protected GroupMapping&MockObject $groupMapper; + protected IJobList&MockObject $jobList; + protected UUIDFixInsert $job; protected function setUp(): void { parent::setUp(); @@ -63,17 +38,16 @@ class UUIDFixInsertTest extends TestCase { ); } - public function testGetName() { + public function testGetName(): void { $this->assertSame('Insert UUIDFix background job for user and group in batches', $this->job->getName()); } - public function recordProvider() { + public static function recordProvider(): array { $record = [ 'dn' => 'cn=somerecord,dc=somewhere', 'name' => 'Something', 'uuid' => 'AB12-3456-CDEF7-8GH9' ]; - array_fill(0, 50, $record); $userBatches = [ 0 => array_fill(0, 50, $record), @@ -90,13 +64,12 @@ class UUIDFixInsertTest extends TestCase { ]; } - public function recordProviderTooLongAndNone() { + public static function recordProviderTooLongAndNone(): array { $record = [ 'dn' => 'cn=somerecord,dc=somewhere', 'name' => 'Something', 'uuid' => 'AB12-3456-CDEF7-8GH9' ]; - array_fill(0, 50, $record); $userBatches = [ 0 => array_fill(0, 50, $record), @@ -113,10 +86,8 @@ class UUIDFixInsertTest extends TestCase { ]; } - /** - * @dataProvider recordProvider - */ - public function testRun($userBatches, $groupBatches) { + #[\PHPUnit\Framework\Attributes\DataProvider('recordProvider')] + public function testRun(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') ->with('user_ldap', 'installed_version', '1.2.1') @@ -124,8 +95,11 @@ class UUIDFixInsertTest extends TestCase { $this->userMapper->expects($this->exactly(3)) ->method('getList') - ->withConsecutive([0, 50], [50, 50], [100, 50]) - ->willReturnOnConsecutiveCalls($userBatches[0], $userBatches[1], $userBatches[2]); + ->willReturnMap([ + [0, 50, false, $userBatches[0]], + [50, 50, false, $userBatches[1]], + [100, 50, false, $userBatches[2]], + ]); $this->groupMapper->expects($this->exactly(1)) ->method('getList') @@ -140,10 +114,8 @@ class UUIDFixInsertTest extends TestCase { $this->job->run($out); } - /** - * @dataProvider recordProviderTooLongAndNone - */ - public function testRunWithManyAndNone($userBatches, $groupBatches) { + #[\PHPUnit\Framework\Attributes\DataProvider('recordProviderTooLongAndNone')] + public function testRunWithManyAndNone(array $userBatches, array $groupBatches): void { $this->config->expects($this->once()) ->method('getAppValue') ->with('user_ldap', 'installed_version', '1.2.1') @@ -151,8 +123,13 @@ class UUIDFixInsertTest extends TestCase { $this->userMapper->expects($this->exactly(5)) ->method('getList') - ->withConsecutive([0, 50], [0, 40], [0, 32], [32, 32], [64, 32]) - ->willReturnOnConsecutiveCalls($userBatches[0], $userBatches[1], $userBatches[2], $userBatches[3], $userBatches[4]); + ->willReturnMap([ + [0, 50, false, $userBatches[0]], + [0, 40, false, $userBatches[1]], + [0, 32, false, $userBatches[2]], + [32, 32, false, $userBatches[3]], + [64, 32, false, $userBatches[4]], + ]); $this->groupMapper->expects($this->once()) ->method('getList') @@ -174,7 +151,7 @@ class UUIDFixInsertTest extends TestCase { $this->job->run($out); } - public function testDonNotRun() { + public function testDonNotRun(): void { $this->config->expects($this->once()) ->method('getAppValue') ->with('user_ldap', 'installed_version', '1.2.1') |