aboutsummaryrefslogtreecommitdiffstats
path: root/apps/oauth2/tests/Db
diff options
context:
space:
mode:
Diffstat (limited to 'apps/oauth2/tests/Db')
-rw-r--r--apps/oauth2/tests/Db/AccessTokenMapperTest.php12
-rw-r--r--apps/oauth2/tests/Db/ClientMapperTest.php22
2 files changed, 21 insertions, 13 deletions
diff --git a/apps/oauth2/tests/Db/AccessTokenMapperTest.php b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
index a248c1e0d38..41a79fe725b 100644
--- a/apps/oauth2/tests/Db/AccessTokenMapperTest.php
+++ b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -7,7 +8,10 @@ namespace OCA\OAuth2\Tests\Db;
use OCA\OAuth2\Db\AccessToken;
use OCA\OAuth2\Db\AccessTokenMapper;
+use OCA\OAuth2\Exceptions\AccessTokenNotFoundException;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IDBConnection;
+use OCP\Server;
use Test\TestCase;
/**
@@ -19,10 +23,10 @@ class AccessTokenMapperTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->accessTokenMapper = new AccessTokenMapper(\OC::$server->getDatabaseConnection(), \OC::$server->get(ITimeFactory::class));
+ $this->accessTokenMapper = new AccessTokenMapper(Server::get(IDBConnection::class), Server::get(ITimeFactory::class));
}
- public function testGetByCode() {
+ public function testGetByCode(): void {
$this->accessTokenMapper->deleteByClientId(1234);
$token = new AccessToken();
$token->setClientId(1234);
@@ -38,8 +42,8 @@ class AccessTokenMapperTest extends TestCase {
}
- public function testDeleteByClientId() {
- $this->expectException(\OCA\OAuth2\Exceptions\AccessTokenNotFoundException::class);
+ public function testDeleteByClientId(): void {
+ $this->expectException(AccessTokenNotFoundException::class);
$this->accessTokenMapper->deleteByClientId(1234);
$token = new AccessToken();
diff --git a/apps/oauth2/tests/Db/ClientMapperTest.php b/apps/oauth2/tests/Db/ClientMapperTest.php
index 3d8b25acbef..2e8d20ad200 100644
--- a/apps/oauth2/tests/Db/ClientMapperTest.php
+++ b/apps/oauth2/tests/Db/ClientMapperTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -7,6 +8,9 @@ namespace OCA\OAuth2\Tests\Db;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
+use OCA\OAuth2\Exceptions\ClientNotFoundException;
+use OCP\IDBConnection;
+use OCP\Server;
use Test\TestCase;
/**
@@ -18,17 +22,17 @@ class ClientMapperTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->clientMapper = new ClientMapper(\OC::$server->getDatabaseConnection());
+ $this->clientMapper = new ClientMapper(Server::get(IDBConnection::class));
}
protected function tearDown(): void {
- $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $query = Server::get(IDBConnection::class)->getQueryBuilder();
$query->delete('oauth2_clients')->execute();
parent::tearDown();
}
- public function testGetByIdentifier() {
+ public function testGetByIdentifier(): void {
$client = new Client();
$client->setClientIdentifier('MyAwesomeClientIdentifier');
$client->setName('Client Name');
@@ -39,13 +43,13 @@ class ClientMapperTest extends TestCase {
$this->assertEquals($client, $this->clientMapper->getByIdentifier('MyAwesomeClientIdentifier'));
}
- public function testGetByIdentifierNotExisting() {
- $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+ public function testGetByIdentifierNotExisting(): void {
+ $this->expectException(ClientNotFoundException::class);
$this->clientMapper->getByIdentifier('MyTotallyNotExistingClient');
}
- public function testGetByUid() {
+ public function testGetByUid(): void {
$client = new Client();
$client->setClientIdentifier('MyNewClient');
$client->setName('Client Name');
@@ -56,13 +60,13 @@ class ClientMapperTest extends TestCase {
$this->assertEquals($client, $this->clientMapper->getByUid($client->getId()));
}
- public function testGetByUidNotExisting() {
- $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+ public function testGetByUidNotExisting(): void {
+ $this->expectException(ClientNotFoundException::class);
$this->clientMapper->getByUid(1234);
}
- public function testGetClients() {
+ public function testGetClients(): void {
$this->assertSame('array', gettype($this->clientMapper->getClients()));
}