From fc383a323fa1e4d8bfa4519b8d9a26cfa255b1c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 3 Jul 2024 13:48:58 +0200 Subject: [PATCH] fix(tests): Adjust the migrator test Signed-off-by: Joas Schilling --- tests/lib/DB/MigratorTest.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index 0ca698bbbe9..a486a39ae3d 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -17,6 +17,8 @@ use Doctrine\DBAL\Schema\SchemaConfig; use OC\DB\Migrator; use OC\DB\OracleMigrator; use OC\DB\SQLiteMigrator; +use OC\DB\TDoctrineParameterTypeMap; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\Types; use OCP\IConfig; use OCP\Security\ISecureRandom; @@ -29,6 +31,8 @@ use OCP\Security\ISecureRandom; * @package Test\DB */ class MigratorTest extends \Test\TestCase { + use TDoctrineParameterTypeMap; + /** * @var \Doctrine\DBAL\Connection $connection */ @@ -74,12 +78,12 @@ class MigratorTest extends \Test\TestCase { protected function tearDown(): void { // Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE) try { - $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp)); + $this->connection->executeStatement('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp)); } catch (Exception $e) { } try { - $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName)); + $this->connection->executeStatement('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName)); } catch (Exception $e) { } parent::tearDown(); @@ -267,28 +271,28 @@ class MigratorTest extends \Test\TestCase { public function dataNotNullEmptyValuesFailOracle(): array { return [ - [ParameterType::BOOLEAN, true, Types::BOOLEAN, false], - [ParameterType::BOOLEAN, false, Types::BOOLEAN, true], + [IQueryBuilder::PARAM_BOOL, true, Types::BOOLEAN, false], + [IQueryBuilder::PARAM_BOOL, false, Types::BOOLEAN, true], - [ParameterType::STRING, 'foo', Types::STRING, false], - [ParameterType::STRING, '', Types::STRING, true], + [IQueryBuilder::PARAM_STR, 'foo', Types::STRING, false], + [IQueryBuilder::PARAM_STR, '', Types::STRING, true], - [ParameterType::INTEGER, 1234, Types::INTEGER, false], - [ParameterType::INTEGER, 0, Types::INTEGER, false], // Integer 0 is not stored as Null and therefor works + [IQueryBuilder::PARAM_INT, 1234, Types::INTEGER, false], + [IQueryBuilder::PARAM_INT, 0, Types::INTEGER, false], // Integer 0 is not stored as Null and therefor works - [ParameterType::STRING, '{"a": 2}', Types::JSON, false], + [IQueryBuilder::PARAM_JSON, '{"a": 2}', Types::JSON, false], ]; } /** * @dataProvider dataNotNullEmptyValuesFailOracle * - * @param int $parameterType + * @param int|string $parameterType * @param bool|int|string $value * @param string $columnType * @param bool $oracleThrows */ - public function testNotNullEmptyValuesFailOracle(int $parameterType, $value, string $columnType, bool $oracleThrows): void { + public function testNotNullEmptyValuesFailOracle(int|string $parameterType, bool|int|string $value, string $columnType, bool $oracleThrows): void { $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); $table->addColumn('id', Types::BIGINT); @@ -308,7 +312,7 @@ class MigratorTest extends \Test\TestCase { $this->connection->insert( $this->tableName, ['id' => 1, 'will_it_blend' => $value], - ['id' => ParameterType::INTEGER, 'will_it_blend' => $parameterType], + ['id' => ParameterType::INTEGER, 'will_it_blend' => $this->convertParameterTypeToDoctrine($parameterType)], ); $this->addToAssertionCount(1);