aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php')
-rw-r--r--apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php104
1 files changed, 41 insertions, 63 deletions
diff --git a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
index 8fae0a44d8f..0a0ff4d84af 100644
--- a/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
+++ b/apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @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: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Tests\Settings\Personal\Security;
@@ -30,30 +13,19 @@ use OC\Authentication\Token\PublicKeyToken;
use OCA\Settings\Settings\Personal\Security\Authtokens;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
+use OCP\Authentication\Token\IToken;
use OCP\ISession;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class AuthtokensTest extends TestCase {
-
- /** @var IAuthTokenProvider|MockObject */
- private $authTokenProvider;
-
- /** @var ISession|MockObject */
- private $session;
-
- /** @var IUserSession|MockObject */
- private $userSession;
-
- /** @var IInitialState|MockObject */
- private $initialState;
-
- /** @var string */
- private $uid;
-
- /** @var Authtokens */
- private $section;
+ private IAuthTokenProvider&MockObject $authTokenProvider;
+ private ISession&MockObject $session;
+ private IUserSession&MockObject $userSession;
+ private IInitialState&MockObject $initialState;
+ private string $uid;
+ private Authtokens $section;
protected function setUp(): void {
parent::setUp();
@@ -73,7 +45,7 @@ class AuthtokensTest extends TestCase {
);
}
- public function testGetForm() {
+ public function testGetForm(): void {
$token1 = new PublicKeyToken();
$token1->setId(100);
$token2 = new PublicKeyToken();
@@ -96,33 +68,39 @@ class AuthtokensTest extends TestCase {
->method('getToken')
->with('session123')
->willReturn($sessionToken);
- $this->initialState->expects($this->at(0))
- ->method('provideInitialState')
- ->with('app_tokens', [
- [
- 'id' => 100,
- 'name' => null,
- 'lastActivity' => 0,
- 'type' => 0,
- 'canDelete' => false,
- 'current' => true,
- 'scope' => ['filesystem' => true],
- 'canRename' => false,
- ],
- [
- 'id' => 200,
- 'name' => null,
- 'lastActivity' => 0,
- 'type' => 0,
- 'canDelete' => true,
- 'scope' => ['filesystem' => true],
- 'canRename' => true,
- ],
- ]);
- $this->initialState->expects($this->at(1))
+ $calls = [
+ [
+ 'app_tokens', [
+ [
+ 'id' => 100,
+ 'name' => null,
+ 'lastActivity' => 0,
+ 'type' => 0,
+ 'canDelete' => false,
+ 'current' => true,
+ 'scope' => [IToken::SCOPE_FILESYSTEM => true],
+ 'canRename' => false,
+ ],
+ [
+ 'id' => 200,
+ 'name' => null,
+ 'lastActivity' => 0,
+ 'type' => 0,
+ 'canDelete' => true,
+ 'scope' => [IToken::SCOPE_FILESYSTEM => true],
+ 'canRename' => true,
+ ],
+ ]
+ ],
+ ['can_create_app_token', true],
+ ];
+ $this->initialState->expects($this->exactly(2))
->method('provideInitialState')
- ->with('can_create_app_token', true);
+ ->willReturnCallback(function () use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$form = $this->section->getForm();