aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-07-01 16:59:47 +0200
committerJoas Schilling <coding@schilljs.com>2024-07-19 11:21:14 +0200
commit829f2b9bc7290c0b1b1a9db373ee26199c9bcc4d (patch)
tree5641e35ffe42897566f58acb1d71a0d9afba4729 /tests/lib
parentbd383627a7ef3cb0a8e608b35de067d341f46da4 (diff)
downloadnextcloud-server-829f2b9bc7290c0b1b1a9db373ee26199c9bcc4d.tar.gz
nextcloud-server-829f2b9bc7290c0b1b1a9db373ee26199c9bcc4d.zip
fix(db): Promote the use of `getDatabaseProvider` to reduce the impage of removed upstream platforms
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/DB/MigrationsTest.php10
-rw-r--r--tests/lib/DB/MigratorTest.php12
-rw-r--r--tests/lib/DB/OCPostgreSqlPlatformTest.php4
-rw-r--r--tests/lib/Files/Cache/CacheTest.php4
-rw-r--r--tests/lib/Repair/RepairCollationTest.php3
5 files changed, 13 insertions, 20 deletions
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 6cd489258bf..2bdd705ff5d 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -8,8 +8,6 @@
namespace Test\DB;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
@@ -326,9 +324,9 @@ class MigrationsTest extends \Test\TestCase {
public function testEnsureOracleConstraintsValidWithPrimaryKeyDefault() {
$defaultName = 'PRIMARY';
- if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+ if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_POSTGRES) {
$defaultName = \str_repeat('a', 26) . '_' . \str_repeat('b', 30) . '_seq';
- } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+ } elseif ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
$defaultName = \str_repeat('a', 26) . '_seq';
}
@@ -407,9 +405,9 @@ class MigrationsTest extends \Test\TestCase {
$this->expectException(\InvalidArgumentException::class);
$defaultName = 'PRIMARY';
- if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+ if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_POSTGRES) {
$defaultName = \str_repeat('a', 27) . '_' . \str_repeat('b', 30) . '_seq';
- } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+ } elseif ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
$defaultName = \str_repeat('a', 27) . '_seq';
}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index eaa6540b93b..d12b70725ed 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -10,8 +10,6 @@ namespace Test\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\ParameterType;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaConfig;
use OC\DB\Migrator;
@@ -19,7 +17,7 @@ use OC\DB\OracleMigrator;
use OC\DB\SQLiteMigrator;
use OCP\DB\Types;
use OCP\IConfig;
-use OCP\Security\ISecureRandom;
+use OCP\IDBConnection;
/**
* Class MigratorTest
@@ -56,12 +54,10 @@ class MigratorTest extends \Test\TestCase {
}
private function getMigrator(): Migrator {
- $platform = $this->connection->getDatabasePlatform();
- $random = \OC::$server->get(ISecureRandom::class);
$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
- if ($platform instanceof SqlitePlatform) {
+ if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
return new SQLiteMigrator($this->connection, $this->config, $dispatcher);
- } elseif ($platform instanceof OraclePlatform) {
+ } elseif ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
return new OracleMigrator($this->connection, $this->config, $dispatcher);
}
return new Migrator($this->connection, $this->config, $dispatcher);
@@ -300,7 +296,7 @@ class MigratorTest extends \Test\TestCase {
$migrator = $this->getMigrator();
$migrator->migrate($startSchema);
- if ($oracleThrows && $this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+ if ($oracleThrows && $this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
// Oracle can not store false|empty string in notnull columns
$this->expectException(\Doctrine\DBAL\Exception\NotNullConstraintViolationException::class);
}
diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php
index 4f83e866a7c..3ed420df501 100644
--- a/tests/lib/DB/OCPostgreSqlPlatformTest.php
+++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php
@@ -7,7 +7,7 @@
namespace Test\DB;
-use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
+use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
@@ -24,7 +24,7 @@ use Doctrine\DBAL\Types\Types;
*/
class OCPostgreSqlPlatformTest extends \Test\TestCase {
public function testAlterBigint() {
- $platform = new PostgreSQL100Platform();
+ $platform = new PostgreSQLPlatform();
$sourceSchema = new Schema();
$targetSchema = new Schema();
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index faecbf54491..a36607eb965 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -7,12 +7,12 @@
namespace Test\Files\Cache;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
use OC\Files\Cache\Cache;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Search\ISearchComparison;
+use OCP\IDBConnection;
use OCP\IUser;
class LongId extends \OC\Files\Storage\Temporary {
@@ -142,7 +142,7 @@ class CacheTest extends \Test\TestCase {
if (strpos($folder, 'F09F9890')) {
// 4 byte UTF doesn't work on mysql
$params = \OC::$server->get(\OC\DB\Connection::class)->getParams();
- if (\OC::$server->getDatabaseConnection()->getDatabasePlatform() instanceof MySqlPlatform && $params['charset'] !== 'utf8mb4') {
+ if (\OC::$server->getDatabaseConnection()->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL && $params['charset'] !== 'utf8mb4') {
$this->markTestSkipped('MySQL doesn\'t support 4 byte UTF-8');
}
}
diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php
index 5f5e0737f77..6d3946b2a85 100644
--- a/tests/lib/Repair/RepairCollationTest.php
+++ b/tests/lib/Repair/RepairCollationTest.php
@@ -7,7 +7,6 @@
namespace Test\Repair;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
use OC\Repair\Collation;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
@@ -61,7 +60,7 @@ class RepairCollationTest extends TestCase {
$this->connection = \OC::$server->get(IDBConnection::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->config = \OC::$server->getConfig();
- if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
+ if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
$this->markTestSkipped("Test only relevant on MySql");
}