diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d335766b3..62b2fe717 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -32,13 +32,19 @@ jobs: - "8.2" dependencies: - "highest" + stability: + - "default" include: - dependencies: "lowest" + stability: "default" php-version: "8.1" + - dependencies: "highest" + stability: "dev" + php-version: "8.2" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -51,6 +57,10 @@ jobs: - name: "Download box" run: "./download-box.sh" + - name: "Allow dev dependencies" + if: "matrix.stability == 'dev'" + run: "composer config minimum-stability dev" + - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" with: diff --git a/composer.json b/composer.json index ec89e8e46..47c95dc1f 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^8.1", "composer-runtime-api": "^2", - "doctrine/dbal": "^3.5.1", + "doctrine/dbal": "^3.5.1 || ^4", "doctrine/deprecations": "^0.5.3 || ^1", "doctrine/event-manager": "^1.2 || ^2.0", "psr/log": "^1.1.3 || ^2 || ^3", @@ -37,7 +37,7 @@ "require-dev": { "ext-pdo_sqlite": "*", "doctrine/coding-standard": "^12", - "doctrine/orm": "^2.13", + "doctrine/orm": "^2.13 || ^3", "doctrine/persistence": "^2 || ^3", "doctrine/sql-formatter": "^1.0", "phpstan/phpstan": "^1.10", @@ -53,6 +53,7 @@ "conflict": { "doctrine/orm": "<2.12" }, + "minimum-stability": "dev", "suggest": { "doctrine/sql-formatter": "Allows to generate formatted SQL with the diff command.", "symfony/yaml": "Allows the use of yaml for migration configuration files." diff --git a/lib/Doctrine/Migrations/DependencyFactory.php b/lib/Doctrine/Migrations/DependencyFactory.php index 24bca9a75..f41910f0b 100644 --- a/lib/Doctrine/Migrations/DependencyFactory.php +++ b/lib/Doctrine/Migrations/DependencyFactory.php @@ -4,6 +4,7 @@ namespace Doctrine\Migrations; +use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Configuration\Connection\ConnectionLoader; @@ -51,6 +52,7 @@ use function array_key_exists; use function call_user_func; +use function method_exists; use function preg_quote; use function sprintf; @@ -67,16 +69,12 @@ class DependencyFactory /** @var object[]|callable[] */ private array $dependencies = []; - private Connection|null $connection = null; - + private Connection|null $connection = null; private EntityManagerInterface|null $em = null; - - private bool $frozen = false; - + private EventManager|null $eventManager = null; + private bool $frozen = false; private ConfigurationLoader $configurationLoader; - private ConnectionLoader $connectionLoader; - private EntityManagerLoader|null $emLoader = null; /** @var callable[] */ @@ -193,7 +191,7 @@ public function getEventDispatcher(): EventDispatcher { return $this->getDependency(EventDispatcher::class, fn (): EventDispatcher => new EventDispatcher( $this->getConnection(), - $this->getConnection()->getEventManager(), + $this->getEventManager(), )); } @@ -446,4 +444,22 @@ public function setDefinition(string $id, callable $service): void $this->assertNotFrozen(); $this->factories[$id] = $service; } + + private function getEventManager(): EventManager + { + if ($this->eventManager) { + return $this->eventManager; + } + + if ($this->hasEntityManager()) { + return $this->eventManager = $this->getEntityManager()->getEventManager(); + } + + if (method_exists(Connection::class, 'getEventManager')) { + // DBAL < 4 + return $this->eventManager = $this->getConnection()->getEventManager(); + } + + return $this->eventManager = new EventManager(); + } } diff --git a/lib/Doctrine/Migrations/Metadata/Storage/TableMetadataStorage.php b/lib/Doctrine/Migrations/Metadata/Storage/TableMetadataStorage.php index 06867ba98..74b88e90d 100644 --- a/lib/Doctrine/Migrations/Metadata/Storage/TableMetadataStorage.php +++ b/lib/Doctrine/Migrations/Metadata/Storage/TableMetadataStorage.php @@ -132,7 +132,7 @@ public function complete(ExecutionResult $result): void $this->configuration->getExecutionTimeColumnName() => $result->getTime() === null ? null : (int) round($result->getTime() * 1000), ], [ Types::STRING, - Types::DATETIME_MUTABLE, + Types::DATETIME_IMMUTABLE, Types::INTEGER, ]); } diff --git a/lib/Doctrine/Migrations/SchemaDumper.php b/lib/Doctrine/Migrations/SchemaDumper.php index a0a6cd480..f1938c9cf 100644 --- a/lib/Doctrine/Migrations/SchemaDumper.php +++ b/lib/Doctrine/Migrations/SchemaDumper.php @@ -80,7 +80,7 @@ public function dump( $up[] = $upCode; } - $downSql = [$this->platform->getDropTableSQL($table)]; + $downSql = [$this->platform->getDropTableSQL($table->getQuotedName($this->platform))]; $downCode = $this->migrationSqlGenerator->generate( $downSql, diff --git a/tests/Doctrine/Migrations/Tests/Configuration/Connection/ConnectionLoaderTest.php b/tests/Doctrine/Migrations/Tests/Configuration/Connection/ConnectionLoaderTest.php index 2debef434..daadbb422 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/Connection/ConnectionLoaderTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/Connection/ConnectionLoaderTest.php @@ -5,7 +5,7 @@ namespace Doctrine\Migrations\Tests\Configuration\Connection; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Migrations\Configuration\Connection\ConfigurationFile; use Doctrine\Migrations\Configuration\Connection\Exception\FileNotFound; use Doctrine\Migrations\Configuration\Connection\Exception\InvalidConfiguration; @@ -39,7 +39,7 @@ public function testArrayConnectionConfigurationLoader(): void $loader = new ConfigurationFile(__DIR__ . '/_files/sqlite-connection.php'); $conn = $loader->getConnection(); - self::assertInstanceOf(SqlitePlatform::class, $conn->getDatabasePlatform()); + self::assertInstanceOf(SQLitePlatform::class, $conn->getDatabasePlatform()); } public function testArrayConnectionConfigurationLoaderWithConnectionInstance(): void @@ -47,7 +47,7 @@ public function testArrayConnectionConfigurationLoaderWithConnectionInstance(): $loader = new ConfigurationFile(__DIR__ . '/_files/sqlite-connection-instance.php'); $conn = $loader->getConnection(); - self::assertInstanceOf(SqlitePlatform::class, $conn->getDatabasePlatform()); + self::assertInstanceOf(SQLitePlatform::class, $conn->getDatabasePlatform()); } public function testArrayConnectionConfigurationLoaderInvalid(): void diff --git a/tests/Doctrine/Migrations/Tests/Configuration/EntityManager/EntityManagerTest.php b/tests/Doctrine/Migrations/Tests/Configuration/EntityManager/EntityManagerTest.php index c954ffa57..66fd48517 100644 --- a/tests/Doctrine/Migrations/Tests/Configuration/EntityManager/EntityManagerTest.php +++ b/tests/Doctrine/Migrations/Tests/Configuration/EntityManager/EntityManagerTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Migrations\Tests\Configuration\EntityManager; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Migrations\Configuration\EntityManager\ConfigurationFile; use Doctrine\Migrations\Configuration\EntityManager\Exception\FileNotFound; use Doctrine\Migrations\Configuration\EntityManager\Exception\InvalidConfiguration; @@ -39,7 +39,7 @@ public function testArrayEntityManagerConfigurationLoader(): void $loader = new ConfigurationFile(__DIR__ . '/_files/em-loader.php'); $em = $loader->getEntityManager(); - self::assertInstanceOf(SqlitePlatform::class, $em->getConnection()->getDatabasePlatform()); + self::assertInstanceOf(SQLitePlatform::class, $em->getConnection()->getDatabasePlatform()); } public function testArrayEntityManagerConfigurationLoaderWithEntityManagerInstance(): void @@ -47,7 +47,7 @@ public function testArrayEntityManagerConfigurationLoaderWithEntityManagerInstan $loader = new ConfigurationFile(__DIR__ . '/_files/migrations-em.php'); $em = $loader->getEntityManager(); - self::assertInstanceOf(SqlitePlatform::class, $em->getConnection()->getDatabasePlatform()); + self::assertInstanceOf(SQLitePlatform::class, $em->getConnection()->getDatabasePlatform()); } public function testArrayEntityManagerConfigurationLoaderInvalid(): void diff --git a/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php b/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php index 6d8235892..24e18f304 100644 --- a/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php +++ b/tests/Doctrine/Migrations/Tests/Event/Listeners/AutoCommitListenerTest.php @@ -5,7 +5,6 @@ namespace Doctrine\Migrations\Tests\Event\Listeners; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\Migrations\Event\Listeners\AutoCommitListener; use Doctrine\Migrations\Event\MigrationsEventArgs; use Doctrine\Migrations\Metadata\MigrationPlanList; @@ -16,9 +15,7 @@ class AutoCommitListenerTest extends MigrationTestCase { - /** @var Connection&MockObject */ - private Connection $conn; - + private Connection&MockObject $conn; private AutoCommitListener $listener; public function testListenerDoesNothingDuringADryRun(): void @@ -51,10 +48,7 @@ public function testListenerDoesFinalCommitWhenAutoCommitIsOff(): void protected function setUp(): void { - $this->conn = $this->createMock(Connection::class); - $driverConnection = self::createStub(DriverConnection::class); - $this->conn->method('getWrappedConnection')->willReturn($driverConnection); - + $this->conn = $this->createMock(Connection::class); $this->listener = new AutoCommitListener(); } diff --git a/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php b/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php index b075ef7f0..f40eda9dd 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/DiffGeneratorTest.php @@ -17,31 +17,21 @@ use Doctrine\Migrations\Provider\SchemaProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use ReflectionMethod; class DiffGeneratorTest extends TestCase { - /** @var DBALConfiguration&MockObject */ - private DBALConfiguration $dbalConfiguration; + private DBALConfiguration&MockObject $dbalConfiguration; /** @var AbstractSchemaManager&MockObject */ - private AbstractSchemaManager $schemaManager; - - /** @var SchemaProvider&MockObject */ - private SchemaProvider $schemaProvider; - - /** @var AbstractPlatform&MockObject */ - private AbstractPlatform $platform; - - /** @var Generator&MockObject */ - private Generator $migrationGenerator; - - /** @var SqlGenerator&MockObject */ - private SqlGenerator $migrationSqlGenerator; + private AbstractSchemaManager&MockObject $schemaManager; + private SchemaProvider&MockObject $schemaProvider; + private AbstractPlatform&MockObject $platform; + private Generator&MockObject $migrationGenerator; + private SqlGenerator&MockObject $migrationSqlGenerator; private DiffGenerator $migrationDiffGenerator; - - /** @var SchemaProvider&MockObject */ - private SchemaProvider $emptySchemaProvider; + private SchemaProvider&MockObject $emptySchemaProvider; public function testGenerate(): void { @@ -89,7 +79,7 @@ public function testGenerate(): void $toSchema->expects(self::exactly(2)) ->method('dropTable') - ->willReturnOnConsecutiveCalls('schema.table_name2', 'schema.table_name3'); + ->willReturnSelf(); $schemaDiff = self::createStub(SchemaDiff::class); @@ -102,19 +92,7 @@ public function testGenerate(): void return ['UPDATE table SET value = 1']; }); - // regular mocks cannot be used here, because the method is static - $comparator = new class extends Comparator { - public static SchemaDiff $schemaDiff; - - public static function compareSchemas( - Schema $fromSchema, - Schema $toSchema, - ): SchemaDiff { - return self::$schemaDiff; - } - }; - - $comparator::$schemaDiff = $schemaDiff; + $comparator = $this->mockComparator($schemaDiff); $this->schemaManager->expects(self::once()) ->method('createComparator') @@ -151,10 +129,10 @@ public function testGenerateFromEmptySchema(): void $this->dbalConfiguration->expects(self::once()) ->method('getSchemaAssetsFilter') - ->willReturn(null); + ->willReturn(static fn () => true); - $toSchema->expects(self::never()) - ->method('getTables'); + $toSchema->method('getTables') + ->willReturn([new Table('table_name')]); $this->emptySchemaProvider->expects(self::once()) ->method('createSchema') @@ -181,18 +159,7 @@ public function testGenerateFromEmptySchema(): void }); // regular mocks cannot be used here, because the method is static - $comparator = new class extends Comparator { - public static SchemaDiff $schemaDiff; - - public static function compareSchemas( - Schema $fromSchema, - Schema $toSchema, - ): SchemaDiff { - return self::$schemaDiff; - } - }; - - $comparator::$schemaDiff = $schemaDiff; + $comparator = $this->mockComparator($schemaDiff); $this->schemaManager->expects(self::once()) ->method('createComparator') @@ -233,4 +200,34 @@ protected function setUp(): void $this->emptySchemaProvider, ); } + + private function mockComparator(SchemaDiff $schemaDiff): Comparator + { + if ((new ReflectionMethod(Comparator::class, 'compareSchemas'))->isStatic()) { + // DBAL 3 + // regular mocks cannot be used here, because the method is static + $comparator = new class extends Comparator { + public static SchemaDiff $schemaDiff; + + public static function compareSchemas(Schema $fromSchema, Schema $toSchema): SchemaDiff + { + return self::$schemaDiff; + } + }; + } else { + // DBAL >= 4 + $comparator = new class ($this->createStub(AbstractPlatform::class)) extends Comparator { + public static SchemaDiff $schemaDiff; + + public function compareSchemas(Schema $oldSchema, Schema $newSchema): SchemaDiff + { + return self::$schemaDiff; + } + }; + } + + $comparator::$schemaDiff = $schemaDiff; + + return $comparator; + } } diff --git a/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php b/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php index 8301d57d0..e84154208 100644 --- a/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php +++ b/tests/Doctrine/Migrations/Tests/Generator/SqlGeneratorTest.php @@ -5,24 +5,23 @@ namespace Doctrine\Migrations\Tests\Generator; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\Generator\SqlGenerator; use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration; use Doctrine\SqlFormatter\NullHighlighter; use Doctrine\SqlFormatter\SqlFormatter; -use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use function class_exists; use function sprintf; +// DBAL 3 compatibility +class_exists('Doctrine\DBAL\Platforms\SqlitePlatform'); + final class SqlGeneratorTest extends TestCase { private Configuration $configuration; - - /** @var AbstractPlatform&MockObject */ - private AbstractPlatform $platform; - private SqlGenerator $migrationSqlGenerator; /** @var string[] */ @@ -33,24 +32,26 @@ final class SqlGeneratorTest extends TestCase public function testGenerate(): void { $configuration = new Configuration(); - $platform = new SqlitePlatform(); + $platform = new SQLitePlatform(); - $metadataConfig = new TableMetadataStorageConfiguration(); $configuration->setMetadataStorageConfiguration($this->metadataConfig); $migrationSqlGenerator = new SqlGenerator($configuration, $platform); $configuration->setCheckDatabasePlatform(true); + // SqlitePlatform on DBAL 3, SQLitePlatform on DBAL >= 4 + $expectedPlatform = $platform::class; + $expectedCode = $this->prepareGeneratedCode( - <<<'CODE' -$this->abortIf( - !$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform, - "Migration can only be executed safely on '\Doctrine\DBAL\Platforms\SqlitePlatform'." -); - -$this->addSql('SELECT 1'); -$this->addSql('SELECT 2'); -$this->addSql('%s'); -CODE, + <<abortIf( + !\$this->connection->getDatabasePlatform() instanceof \\$expectedPlatform, + "Migration can only be executed safely on '\\$expectedPlatform'." + ); + + \$this->addSql('SELECT 1'); + \$this->addSql('SELECT 2'); + \$this->addSql('%s'); + CODE, ); $code = $migrationSqlGenerator->generate($this->sql, true, 80); @@ -64,10 +65,10 @@ public function testGenerationWithoutCheckingDatabasePlatform(): void $expectedCode = $this->prepareGeneratedCode( <<<'CODE' -$this->addSql('SELECT 1'); -$this->addSql('SELECT 2'); -$this->addSql('%s'); -CODE, + $this->addSql('SELECT 1'); + $this->addSql('SELECT 2'); + $this->addSql('%s'); + CODE, ); $code = $this->migrationSqlGenerator->generate($this->sql, true, 80, false); @@ -81,10 +82,10 @@ public function testGenerationWithoutCheckingDatabasePlatformWithConfiguration() $expectedCode = $this->prepareGeneratedCode( <<<'CODE' -$this->addSql('SELECT 1'); -$this->addSql('SELECT 2'); -$this->addSql('%s'); -CODE, + $this->addSql('SELECT 1'); + $this->addSql('SELECT 2'); + $this->addSql('%s'); + CODE, ); $code = $this->migrationSqlGenerator->generate($this->sql, true, 80); @@ -95,13 +96,13 @@ public function testGenerationWithoutCheckingDatabasePlatformWithConfiguration() protected function setUp(): void { $this->configuration = new Configuration(); - $this->platform = $this->createMock(AbstractPlatform::class); + $platform = $this->createMock(AbstractPlatform::class); $this->metadataConfig = new TableMetadataStorageConfiguration(); $this->configuration->setMetadataStorageConfiguration($this->metadataConfig); $this->migrationSqlGenerator = new SqlGenerator( $this->configuration, - $this->platform, + $platform, ); } diff --git a/tests/Doctrine/Migrations/Tests/Metadata/Storage/TableMetadataStorageTest.php b/tests/Doctrine/Migrations/Tests/Metadata/Storage/TableMetadataStorageTest.php index 164814c27..8e1d772bf 100644 --- a/tests/Doctrine/Migrations/Tests/Metadata/Storage/TableMetadataStorageTest.php +++ b/tests/Doctrine/Migrations/Tests/Metadata/Storage/TableMetadataStorageTest.php @@ -239,7 +239,7 @@ public function testCompleteWillAlwaysCastTimeToInteger(): void ], $params); self::assertSame([ Types::STRING, - Types::DATETIME_MUTABLE, + Types::DATETIME_IMMUTABLE, Types::INTEGER, ], $types); diff --git a/tests/Doctrine/Migrations/Tests/MigratorTest.php b/tests/Doctrine/Migrations/Tests/MigratorTest.php index 134660d1f..bfe910d8c 100644 --- a/tests/Doctrine/Migrations/Tests/MigratorTest.php +++ b/tests/Doctrine/Migrations/Tests/MigratorTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\Migrations\Configuration\Configuration; use Doctrine\Migrations\DbalMigrator; use Doctrine\Migrations\EventDispatcher; @@ -22,7 +21,6 @@ use Doctrine\Migrations\Tests\Stub\NonTransactional\MigrationNonTransactional; use Doctrine\Migrations\Version\DbalExecutor; use Doctrine\Migrations\Version\Direction; -use Doctrine\Migrations\Version\Executor; use Doctrine\Migrations\Version\Version; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Output\StreamOutput; @@ -36,25 +34,15 @@ class MigratorTest extends MigrationTestCase { - /** @var Connection&MockObject */ - private Connection $conn; - + private Connection&MockObject $conn; private Configuration $config; - protected StreamOutput $output; - private MigratorConfiguration $migratorConfiguration; - - private Executor $executor; - private TestLogger $logger; protected function setUp(): void { - $this->conn = $this->createMock(Connection::class); - $driverConnection = self::createStub(DriverConnection::class); - $this->conn->method('getWrappedConnection')->willReturn($driverConnection); - + $this->conn = $this->createMock(Connection::class); $this->config = new Configuration(); $this->migratorConfiguration = new MigratorConfiguration(); @@ -107,9 +95,13 @@ protected function createTestMigrator(): DbalMigrator $storage = $this->createMock(MetadataStorage::class); $schemaDiff = $this->createMock(SchemaDiffProvider::class); - $this->executor = new DbalExecutor($storage, $eventDispatcher, $this->conn, $schemaDiff, $this->logger, $paramFormatter, $stopwatch); - - return new DbalMigrator($this->conn, $eventDispatcher, $this->executor, $this->logger, $stopwatch); + return new DbalMigrator( + $this->conn, + $eventDispatcher, + new DbalExecutor($storage, $eventDispatcher, $this->conn, $schemaDiff, $this->logger, $paramFormatter, $stopwatch), + $this->logger, + $stopwatch, + ); } public function testMigrateAllOrNothing(): void diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php index 10a156cda..7b003f96a 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/ConsoleRunnerTest.php @@ -4,10 +4,11 @@ namespace Doctrine\Migrations\Tests\Tools\Console; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\SQLitePlatform; use Doctrine\Migrations\DependencyFactory; use Doctrine\Migrations\Tools\Console\ConsoleRunner; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Component\Console\Application; @@ -26,6 +27,10 @@ class ConsoleRunnerTest extends TestCase public function testCreateDependencyFactoryFromLegacyOrmHelper(): void { + if (! class_exists(EntityManagerHelper::class)) { + self::markTestSkipped('This test requires ORM < 3.'); + } + $dir = getcwd(); if ($dir === false) { $dir = '.'; @@ -36,7 +41,7 @@ public function testCreateDependencyFactoryFromLegacyOrmHelper(): void try { $dependencyFactory = ConsoleRunnerStub::findDependencyFactory(); self::assertInstanceOf(DependencyFactory::class, $dependencyFactory); - self::assertInstanceOf(SqlitePlatform::class, $dependencyFactory->getConnection()->getDatabasePlatform()); + self::assertInstanceOf(SQLitePlatform::class, $dependencyFactory->getConnection()->getDatabasePlatform()); self::assertInstanceOf(EntityManager::class, $dependencyFactory->getEntityManager()); } finally { chdir($dir); diff --git a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php index 88f410fdb..31acf865d 100644 --- a/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php +++ b/tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\Migrations\EventDispatcher; use Doctrine\Migrations\Events; use Doctrine\Migrations\Metadata\MigrationPlan; @@ -222,7 +221,7 @@ public function testExecuteDryRun(): void $this->connection ->expects(self::never()) - ->method('executeUpdate'); + ->method('executeStatement'); $migratorConfiguration = (new MigratorConfiguration()) ->setDryRun(true) @@ -507,9 +506,7 @@ protected function setUp(): void // use FutureMetadataStorage until getSql is added to MetadataStorage interface $this->metadataStorage = $this->createMock(FutureMetadataStorage::class); - $this->connection = $this->createMock(Connection::class); - $driverConnection = self::createStub(DriverConnection::class); - $this->connection->method('getWrappedConnection')->willReturn($driverConnection); + $this->connection = $this->createMock(Connection::class); $this->schemaDiffProvider = $this->createMock(SchemaDiffProvider::class); $this->parameterFormatter = $this->createMock(ParameterFormatter::class);