diff options
Diffstat (limited to 'apps/oauth2/tests')
-rw-r--r-- | apps/oauth2/tests/Controller/SettingsControllerTest.php | 41 | ||||
-rw-r--r-- | apps/oauth2/tests/Settings/AdminTest.php | 21 |
2 files changed, 17 insertions, 45 deletions
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php index 4e4a69c9405..a14d7aad782 100644 --- a/apps/oauth2/tests/Controller/SettingsControllerTest.php +++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php @@ -144,47 +144,6 @@ class SettingsControllerTest extends TestCase { $this->assertEquals([], $result->getData()); } - public function testGetClients() { - $client1 = new Client(); - $client1->setId(123); - $client1->setName('My Client Name'); - $client1->setRedirectUri('https://example.com/'); - $client1->setSecret('MySecret'); - $client1->setClientIdentifier('MyClientIdentifier'); - - $client2 = new Client(); - $client2->setId(42); - $client2->setName('My Client Name2'); - $client2->setRedirectUri('https://example.com/2'); - $client2->setSecret('MySecret2'); - $client2->setClientIdentifier('MyClientIdentifier2'); - - $this->clientMapper->method('getClients') - ->willReturn([$client1, $client2]); - - $result = $this->settingsController->getClients(); - $this->assertInstanceOf(JSONResponse::class, $result); - - $data = $result->getData(); - - $this->assertSame([ - [ - 'id' => 123, - 'name' => 'My Client Name', - 'redirectUri' => 'https://example.com/', - 'clientId' => 'MyClientIdentifier', - 'clientSecret' => 'MySecret', - ], - [ - 'id' => 42, - 'name' => 'My Client Name2', - 'redirectUri' => 'https://example.com/2', - 'clientId' => 'MyClientIdentifier2', - 'clientSecret' => 'MySecret2', - ], - ], $data); - } - public function testInvalidRedirectUri() { $result = $this->settingsController->addClient('test', 'invalidurl'); diff --git a/apps/oauth2/tests/Settings/AdminTest.php b/apps/oauth2/tests/Settings/AdminTest.php index 022ae913e1e..c09a7b3420c 100644 --- a/apps/oauth2/tests/Settings/AdminTest.php +++ b/apps/oauth2/tests/Settings/AdminTest.php @@ -1,4 +1,5 @@ <?php + /** * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> * @@ -21,26 +22,38 @@ namespace OCA\OAuth2\Tests\Settings; +use OCA\OAuth2\Db\ClientMapper; use OCA\OAuth2\Settings\Admin; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IInitialStateService; use Test\TestCase; +use PHPUnit\Framework\MockObject\MockObject; class AdminTest extends TestCase { - /** @var Admin|\PHPUnit_Framework_MockObject_MockObject */ + + /** @var Admin|MockObject */ private $admin; + /** @var IInitialStateService|MockObject */ + private $initialStateService; + + /** @var ClientMapper|MockObject */ + private $clientMapper; + public function setUp() { parent::setUp(); - $this->admin = new Admin(); + $this->initialStateService = $this->createMock(IInitialStateService::class); + $this->clientMapper = $this->createMock(ClientMapper::class); + + $this->admin = new Admin($this->initialStateService, $this->clientMapper); } public function testGetForm() { $expected = new TemplateResponse( 'oauth2', 'admin', - [ - ], + [], '' ); $this->assertEquals($expected, $this->admin->getForm()); |