Skip to content

Commit

Permalink
minor #37141 [Messenger] fix forward compatibility with Doctrine DBAL…
Browse files Browse the repository at this point in the history
… 2.11+ (xabbuh)

This PR was merged into the 5.1 branch.

Discussion
----------

[Messenger] fix forward compatibility with Doctrine DBAL 2.11+

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

The methods will be deprecated in 2.11 (see doctrine/dbal#4019), but the forward compatibility layer is only present in 3.0 (see doctrine/dbal#4007).

Commits
-------

bca4f9970b fix forward compatibility with Doctrine DBAL 2.11+
  • Loading branch information
fabpot authored and nicolas-grekas committed Jun 9, 2020
1 parent a97df38 commit 5b1f455
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Tests/Transport/Doctrine/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Query\QueryBuilder;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\SchemaConfig;
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
use Doctrine\DBAL\Statement;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Transport\Doctrine\Connection;
Expand Down Expand Up @@ -145,14 +145,10 @@ private function getQueryBuilderMock()

private function getStatementMock($expectedResult): ResultStatement
{
$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
? ForwardCompatibleResultStatement::class
: ResultStatement::class;

$stmt = $this->createMock($mockedInterface);
$stmt = $this->createMock(Statement::class);

$stmt->expects($this->once())
->method(method_exists($mockedInterface, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
->method(method_exists(Statement::class, 'fetchAssociative') ? 'fetchAssociative' : 'fetch')
->willReturn($expectedResult);

return $stmt;
Expand Down Expand Up @@ -312,12 +308,9 @@ public function testFindAll()
'headers' => json_encode(['type' => DummyMessage::class]),
];

$mockedInterface = interface_exists(ForwardCompatibleResultStatement::class)
? ForwardCompatibleResultStatement::class
: ResultStatement::class;
$stmt = $this->createMock($mockedInterface);
$stmt = $this->createMock(Statement::class);
$stmt->expects($this->once())
->method(method_exists($mockedInterface, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
->method(method_exists(Statement::class, 'fetchAllAssociative') ? 'fetchAllAssociative' : 'fetchAll')
->willReturn([$message1, $message2]);

$driverConnection
Expand Down

0 comments on commit 5b1f455

Please sign in to comment.