aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-07-19 16:40:49 +0200
committerGitHub <noreply@github.com>2024-07-19 16:40:49 +0200
commit7395211c1a5bf435e3be66d7a021f6cbb99ab1ab (patch)
treec958695ffa44082bf971b2f223f3a81606b1f738 /tests
parent8f975cda34b4b4f181646a54c15f7c511d6e8491 (diff)
parentb656edc47c50376140971e11d1325147cb1e49c9 (diff)
downloadnextcloud-server-7395211c1a5bf435e3be66d7a021f6cbb99ab1ab.tar.gz
nextcloud-server-7395211c1a5bf435e3be66d7a021f6cbb99ab1ab.zip
Merge pull request #46605 from nextcloud/bugfix/noid/test-more-oracle-versions
fix(deps): Deprecate functionality deprecated by doctrine and test on more oracle versions
Diffstat (limited to 'tests')
-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/DB/QueryBuilder/ExpressionBuilderTest.php7
-rw-r--r--tests/lib/Files/Cache/CacheTest.php4
-rw-r--r--tests/lib/Repair/RepairCollationTest.php5
-rw-r--r--tests/lib/SystemTag/SystemTagObjectMapperTest.php1
7 files changed, 21 insertions, 22 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/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index d8147035b16..5c9482419d9 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -10,6 +10,7 @@ namespace Test\DB\QueryBuilder;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
/**
@@ -32,15 +33,19 @@ class ExpressionBuilderTest extends TestCase {
/** @var \Doctrine\DBAL\Connection */
protected $internalConnection;
+ /** @var LoggerInterface */
+ protected $logger;
+
protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
$this->internalConnection = \OC::$server->get(\OC\DB\Connection::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$queryBuilder = $this->createMock(IQueryBuilder::class);
- $this->expressionBuilder = new ExpressionBuilder($this->connection, $queryBuilder);
+ $this->expressionBuilder = new ExpressionBuilder($this->connection, $queryBuilder, $this->logger);
$this->doctrineExpressionBuilder = new DoctrineExpressionBuilder($this->internalConnection);
}
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 55bda8337c9..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");
}
@@ -73,7 +72,7 @@ class RepairCollationTest extends TestCase {
}
protected function tearDown(): void {
- $this->connection->getInner()->getSchemaManager()->dropTable($this->tableName);
+ $this->connection->getInner()->createSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index c9aff9f5183..7beb1c1f1e1 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -152,6 +152,7 @@ class SystemTagObjectMapperTest extends TestCase {
[$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
'testtype'
);
+ sort($objectIds);
$this->assertEquals([
'1',