Fix AdminTests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
1ccb36a0f1
commit
27259ea2a2
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
|
@ -21,25 +22,12 @@
|
|||
|
||||
namespace OCA\OAuth2\Settings;
|
||||
|
||||
use OCA\OAuth2\Db\ClientMapper;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Settings\ISettings;
|
||||
|
||||
class Admin implements ISettings {
|
||||
/** @var ClientMapper */
|
||||
private $clientMapper;
|
||||
|
||||
/**
|
||||
* @param ClientMapper $clientMapper
|
||||
*/
|
||||
public function __construct(ClientMapper $clientMapper) {
|
||||
$this->clientMapper = $clientMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
public function getForm(): TemplateResponse {
|
||||
return new TemplateResponse(
|
||||
'oauth2',
|
||||
'admin',
|
||||
|
@ -48,17 +36,11 @@ class Admin implements ISettings {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSection() {
|
||||
public function getSection(): string {
|
||||
return 'security';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,35 +21,25 @@
|
|||
|
||||
namespace OCA\OAuth2\Tests\Settings;
|
||||
|
||||
use OCA\OAuth2\Db\ClientMapper;
|
||||
use OCA\OAuth2\Settings\Admin;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use Test\TestCase;
|
||||
|
||||
class AdminTest extends TestCase {
|
||||
/** @var ClientMapper|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $clientMapper;
|
||||
/** @var Admin|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $admin;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->clientMapper = $this->createMock(ClientMapper::class);
|
||||
$this->admin = new Admin($this->clientMapper);
|
||||
$this->admin = new Admin();
|
||||
}
|
||||
|
||||
public function testGetForm() {
|
||||
$this->clientMapper
|
||||
->expects($this->once())
|
||||
->method('getClients')
|
||||
->willReturn(['MyClients']);
|
||||
|
||||
$expected = new TemplateResponse(
|
||||
'oauth2',
|
||||
'admin',
|
||||
[
|
||||
'clients' => ['MyClients'],
|
||||
],
|
||||
''
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue