diff options
Diffstat (limited to 'apps/twofactor_backupcodes/tests/Unit/Service')
-rw-r--r-- | apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php | 60 |
1 files changed, 16 insertions, 44 deletions
diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php index 100b70583fe..069e50b71fd 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php @@ -3,27 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @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: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\TwoFactorBackupCodes\Tests\Unit\Service; @@ -35,24 +16,15 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IUser; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class BackupCodeStorageTest extends TestCase { - - /** @var BackupCodeMapper|\PHPUnit\Framework\MockObject\MockObject */ - private $mapper; - - /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */ - private $random; - - /** @var IHasher|\PHPUnit\Framework\MockObject\MockObject */ - private $hasher; - - /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ - private $eventDispatcher; - - /** @var BackupCodeStorage */ - private $storage; + private BackupCodeMapper&MockObject $mapper; + private ISecureRandom&MockObject $random; + private IHasher&MockObject $hasher; + private IEventDispatcher&MockObject $eventDispatcher; + private BackupCodeStorage $storage; protected function setUp(): void { parent::setUp(); @@ -65,7 +37,7 @@ class BackupCodeStorageTest extends TestCase { $this->storage = new BackupCodeStorage($this->mapper, $this->random, $this->hasher, $this->eventDispatcher); } - public function testCreateCodes() { + public function testCreateCodes(): void { $user = $this->createMock(IUser::class); $number = 5; $user->method('getUID')->willReturn('fritz'); @@ -97,7 +69,7 @@ class BackupCodeStorageTest extends TestCase { } } - public function testHasBackupCodes() { + public function testHasBackupCodes(): void { $user = $this->createMock(IUser::class); $codes = [ new BackupCode(), @@ -112,7 +84,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertTrue($this->storage->hasBackupCodes($user)); } - public function testHasBackupCodesNoCodes() { + public function testHasBackupCodesNoCodes(): void { $user = $this->createMock(IUser::class); $codes = []; @@ -124,7 +96,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertFalse($this->storage->hasBackupCodes($user)); } - public function testGetBackupCodeState() { + public function testGetBackupCodeState(): void { $user = $this->createMock(IUser::class); $code1 = new BackupCode(); @@ -149,7 +121,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertEquals($expected, $this->storage->getBackupCodesState($user)); } - public function testGetBackupCodeDisabled() { + public function testGetBackupCodeDisabled(): void { $user = $this->createMock(IUser::class); $codes = []; @@ -167,7 +139,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertEquals($expected, $this->storage->getBackupCodesState($user)); } - public function testValidateCode() { + public function testValidateCode(): void { $user = $this->createMock(IUser::class); $code = new BackupCode(); $code->setUsed(0); @@ -193,7 +165,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertEquals(1, $code->getUsed()); } - public function testValidateUsedCode() { + public function testValidateUsedCode(): void { $user = $this->createMock(IUser::class); $code = new BackupCode(); $code->setUsed('1'); @@ -214,7 +186,7 @@ class BackupCodeStorageTest extends TestCase { $this->assertFalse($this->storage->validateCode($user, 'CHALLENGE')); } - public function testValidateCodeWithWrongHash() { + public function testValidateCodeWithWrongHash(): void { $user = $this->createMock(IUser::class); $code = new BackupCode(); $code->setUsed(0); |