2017-05-18 13:09:59 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2017-05-18 13:09:59 -04:00
|
|
|
/**
|
2024-05-30 14:13:41 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-05-18 13:09:59 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\OAuth2\Tests\Settings;
|
|
|
|
|
|
2019-09-26 14:12:24 -04:00
|
|
|
use OCA\OAuth2\Db\ClientMapper;
|
2017-05-18 13:09:59 -04:00
|
|
|
use OCA\OAuth2\Settings\Admin;
|
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2022-05-20 11:07:21 -04:00
|
|
|
use OCP\AppFramework\Services\IInitialState;
|
|
|
|
|
use OCP\IURLGenerator;
|
2019-09-26 14:12:24 -04:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2023-06-08 07:02:40 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
2019-11-22 14:52:10 -05:00
|
|
|
use Test\TestCase;
|
2017-05-18 13:09:59 -04:00
|
|
|
|
|
|
|
|
class AdminTest extends TestCase {
|
2019-09-26 14:12:24 -04:00
|
|
|
|
|
|
|
|
/** @var Admin|MockObject */
|
2017-05-18 13:09:59 -04:00
|
|
|
private $admin;
|
|
|
|
|
|
2024-08-29 11:28:01 -04:00
|
|
|
/** @var IInitialState|MockObject */
|
2022-05-20 11:07:21 -04:00
|
|
|
private $initialState;
|
2019-09-26 14:12:24 -04:00
|
|
|
|
|
|
|
|
/** @var ClientMapper|MockObject */
|
|
|
|
|
private $clientMapper;
|
|
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2017-05-18 13:09:59 -04:00
|
|
|
parent::setUp();
|
|
|
|
|
|
2022-05-20 11:07:21 -04:00
|
|
|
$this->initialState = $this->createMock(IInitialState::class);
|
2019-09-26 14:12:24 -04:00
|
|
|
$this->clientMapper = $this->createMock(ClientMapper::class);
|
|
|
|
|
|
2023-06-08 07:02:40 -04:00
|
|
|
$this->admin = new Admin(
|
|
|
|
|
$this->initialState,
|
|
|
|
|
$this->clientMapper,
|
|
|
|
|
$this->createMock(IURLGenerator::class),
|
|
|
|
|
$this->createMock(LoggerInterface::class)
|
|
|
|
|
);
|
2017-05-18 13:09:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetForm(): void {
|
|
|
|
|
$expected = new TemplateResponse(
|
|
|
|
|
'oauth2',
|
|
|
|
|
'admin',
|
2019-09-26 14:12:24 -04:00
|
|
|
[],
|
2017-05-18 13:09:59 -04:00
|
|
|
''
|
|
|
|
|
);
|
|
|
|
|
$this->assertEquals($expected, $this->admin->getForm());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSection(): void {
|
|
|
|
|
$this->assertSame('security', $this->admin->getSection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetPriority(): void {
|
2019-07-01 03:52:27 -04:00
|
|
|
$this->assertSame(100, $this->admin->getPriority());
|
2017-05-18 13:09:59 -04:00
|
|
|
}
|
|
|
|
|
}
|