aboutsummaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php')
-rw-r--r--apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php55
1 files changed, 16 insertions, 39 deletions
diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
index 6c474ffd9a3..cfc35e7cb1c 100644
--- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
@@ -3,63 +3,40 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @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\Service;
use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage;
+use OCP\IUser;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
+use OCP\Server;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
/**
* @group DB
*/
class BackupCodeStorageTest extends TestCase {
-
- /** @var BackupCodeStorage */
- private $storage;
-
- /** @var string */
- private $testUID = 'test123456789';
-
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
- private $notificationManager;
+ private IManager&MockObject $notificationManager;
+ private string $testUID = 'test123456789';
+ private BackupCodeStorage $storage;
protected function setUp(): void {
parent::setUp();
- $this->storage = \OC::$server->query(BackupCodeStorage::class);
+ $this->storage = Server::get(BackupCodeStorage::class);
$this->notificationManager = $this->createMock(IManager::class);
$this->notificationManager->method('createNotification')
- ->willReturn(\OC::$server->query(IManager::class)->createNotification());
+ ->willReturn(Server::get(IManager::class)->createNotification());
$this->overwriteService(IManager::class, $this->notificationManager);
}
- public function testSimpleWorkFlow() {
- $user = $this->getMockBuilder(\OCP\IUser::class)->getMock();
+ public function testSimpleWorkFlow(): void {
+ $user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
->willReturn($this->testUID);
@@ -67,10 +44,10 @@ class BackupCodeStorageTest extends TestCase {
$this->notificationManager->expects($this->once())
->method('markProcessed')
->with($this->callback(function (INotification $notification) {
- return $notification->getUser() === $this->testUID &&
- $notification->getObjectType() === 'create' &&
- $notification->getObjectId() === 'codes' &&
- $notification->getApp() === 'twofactor_backupcodes';
+ return $notification->getUser() === $this->testUID
+ && $notification->getObjectType() === 'create'
+ && $notification->getObjectId() === 'codes'
+ && $notification->getApp() === 'twofactor_backupcodes';
}));
// Create codes