|
21 | 21 | use Doctrine\DBAL\Platforms\MySQL57Platform;
|
22 | 22 | use Doctrine\DBAL\Platforms\MySQLPlatform;
|
23 | 23 | use Doctrine\DBAL\Platforms\OraclePlatform;
|
| 24 | +use Doctrine\DBAL\Platforms\SQLServer\SQL\Builder\SQLServerSelectSQLBuilder; |
24 | 25 | use Doctrine\DBAL\Platforms\SQLServer2012Platform;
|
25 | 26 | use Doctrine\DBAL\Platforms\SQLServerPlatform;
|
26 | 27 | use Doctrine\DBAL\Query\QueryBuilder;
|
@@ -82,6 +83,9 @@ public function testGetWithNoPendingMessageWillReturnNull()
|
82 | 83 | $queryBuilder
|
83 | 84 | ->method('getParameterTypes')
|
84 | 85 | ->willReturn([]);
|
| 86 | + $queryBuilder |
| 87 | + ->method('getSQL') |
| 88 | + ->willReturn('SELECT FOR UPDATE'); |
85 | 89 | $driverConnection->expects($this->once())
|
86 | 90 | ->method('createQueryBuilder')
|
87 | 91 | ->willReturn($queryBuilder);
|
@@ -120,7 +124,11 @@ private function getDBALConnectionMock()
|
120 | 124 | {
|
121 | 125 | $driverConnection = $this->createMock(DBALConnection::class);
|
122 | 126 | $platform = $this->createMock(AbstractPlatform::class);
|
123 |
| - $platform->method('getWriteLockSQL')->willReturn('FOR UPDATE'); |
| 127 | + |
| 128 | + if (!method_exists(QueryBuilder::class, 'forUpdate')) { |
| 129 | + $platform->method('getWriteLockSQL')->willReturn('FOR UPDATE'); |
| 130 | + } |
| 131 | + |
124 | 132 | $configuration = $this->createMock(\Doctrine\DBAL\Configuration::class);
|
125 | 133 | $driverConnection->method('getDatabasePlatform')->willReturn($platform);
|
126 | 134 | $driverConnection->method('getConfiguration')->willReturn($configuration);
|
@@ -381,7 +389,9 @@ public function testGeneratedSql(AbstractPlatform $platform, string $expectedSql
|
381 | 389 | $driverConnection
|
382 | 390 | ->expects($this->once())
|
383 | 391 | ->method('executeQuery')
|
384 |
| - ->with($expectedSql) |
| 392 | + ->with($this->callback(function ($sql) use ($expectedSql) { |
| 393 | + return trim($expectedSql) === trim($sql); |
| 394 | + })) |
385 | 395 | ->willReturn($result)
|
386 | 396 | ;
|
387 | 397 | $driverConnection->expects($this->once())->method('commit');
|
@@ -415,6 +425,12 @@ class_exists(SQLServerPlatform::class) && !class_exists(SQLServer2012Platform::c
|
415 | 425 | new OraclePlatform(),
|
416 | 426 | 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC FETCH NEXT 1 ROWS ONLY) FOR UPDATE',
|
417 | 427 | ];
|
| 428 | + } elseif (method_exists(QueryBuilder::class, 'forUpdate')) { |
| 429 | + // DBAL >= 3.8 |
| 430 | + yield 'Oracle' => [ |
| 431 | + new OraclePlatform(), |
| 432 | + 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT a.id FROM (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1 FOR UPDATE)', |
| 433 | + ]; |
418 | 434 | } else {
|
419 | 435 | // DBAL < 4
|
420 | 436 | yield 'Oracle' => [
|
|
0 commit comments