Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7c3ab1

Browse files
committed
Get Database platform from connection
1 parent daae218 commit a7c3ab1

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportFactoryTest.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,10 @@ public function testCreateTransport()
4545
$driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
4646
$schemaManager = $this->createMock(AbstractSchemaManager::class);
4747
$schemaConfig = $this->createMock(SchemaConfig::class);
48-
$schemaManager->method('createSchemaConfig')->willReturn($schemaConfig);
49-
5048
$platform = $this->createMock(AbstractPlatform::class);
51-
$driver = $this->createMock(Driver::class);
52-
$driver->expects($this->once())
53-
->method('getDatabasePlatform')
54-
->willReturn($platform);
55-
49+
$schemaManager->method('createSchemaConfig')->willReturn($schemaConfig);
5650
$driverConnection->method('getSchemaManager')->willReturn($schemaManager);
57-
$driverConnection->method('getDriver')->willReturn($driver);
51+
$driverConnection->method('getDatabasePlatform')->willReturn($platform);
5852
$registry = $this->createMock(ConnectionRegistry::class);
5953

6054
$registry->expects($this->once())
@@ -75,16 +69,10 @@ public function testCreateTransportNotifyWithPostgreSQLPlatform()
7569
$driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
7670
$schemaManager = $this->createMock(AbstractSchemaManager::class);
7771
$schemaConfig = $this->createMock(SchemaConfig::class);
78-
$schemaManager->method('createSchemaConfig')->willReturn($schemaConfig);
79-
8072
$platform = $this->createMock(PostgreSQLPlatform::class);
81-
$driver = $this->createMock(Driver::class);
82-
$driver->expects($this->once())
83-
->method('getDatabasePlatform')
84-
->willReturn($platform);
85-
73+
$schemaManager->method('createSchemaConfig')->willReturn($schemaConfig);
8674
$driverConnection->method('getSchemaManager')->willReturn($schemaManager);
87-
$driverConnection->method('getDriver')->willReturn($driver);
75+
$driverConnection->method('getDatabasePlatform')->willReturn($platform);
8876
$registry = $this->createMock(ConnectionRegistry::class);
8977

9078
$registry->expects($this->once())

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function createTransport(string $dsn, array $options, SerializerInterface
4848
throw new TransportException(sprintf('Could not find Doctrine connection from Messenger DSN "%s".', $dsn), 0, $e);
4949
}
5050

51-
if ($useNotify && $driverConnection->getDriver()->getDatabasePlatform() instanceof PostgreSQLPlatform) {
51+
if ($useNotify && $driverConnection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
5252
$connection = new PostgreSqlConnection($configuration, $driverConnection);
5353
} else {
5454
$connection = new Connection($configuration, $driverConnection);

0 commit comments

Comments
 (0)