|
44 | 44 | use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileEmailChanged; |
45 | 45 | use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId; |
46 | 46 | use PDO; |
| 47 | +use Pdo\Pgsql; |
47 | 48 | use PHPUnit\Framework\Attributes\CoversClass; |
| 49 | +use PHPUnit\Framework\Attributes\RequiresPhp; |
48 | 50 | use PHPUnit\Framework\TestCase; |
49 | 51 | use Psr\Clock\ClockInterface; |
50 | 52 | use RuntimeException; |
@@ -1367,7 +1369,43 @@ public function testSetupSubscriptionNotPostgres(): void |
1367 | 1369 | $doctrineDbalStore->setupSubscription(); |
1368 | 1370 | } |
1369 | 1371 |
|
| 1372 | + #[RequiresPhp('>= 8.4')] |
1370 | 1373 | public function testWait(): void |
| 1374 | + { |
| 1375 | + $nativeConnection = $this->createMock(Pgsql::class); |
| 1376 | + $nativeConnection |
| 1377 | + ->expects($this->once()) |
| 1378 | + ->method('getNotify') |
| 1379 | + ->with(PDO::FETCH_ASSOC, 100) |
| 1380 | + ->willReturn([]); |
| 1381 | + |
| 1382 | + $connection = $this->createMock(Connection::class); |
| 1383 | + $connection |
| 1384 | + ->expects($this->once()) |
| 1385 | + ->method('executeStatement') |
| 1386 | + ->with('LISTEN "event_store"') |
| 1387 | + ->willReturn(1); |
| 1388 | + $connection |
| 1389 | + ->expects($this->once()) |
| 1390 | + ->method('getNativeConnection') |
| 1391 | + ->willReturn($nativeConnection); |
| 1392 | + |
| 1393 | + $abstractPlatform = $this->createMock(PostgreSQLPlatform::class); |
| 1394 | + $connection->method('getDatabasePlatform')->willReturn($abstractPlatform); |
| 1395 | + |
| 1396 | + $eventSerializer = $this->createMock(EventSerializer::class); |
| 1397 | + $headersSerializer = $this->createMock(HeadersSerializer::class); |
| 1398 | + |
| 1399 | + $doctrineDbalStore = new StreamDoctrineDbalStore( |
| 1400 | + $connection, |
| 1401 | + $eventSerializer, |
| 1402 | + $headersSerializer, |
| 1403 | + ); |
| 1404 | + $doctrineDbalStore->wait(100); |
| 1405 | + } |
| 1406 | + |
| 1407 | + #[RequiresPhp('< 8.4')] |
| 1408 | + public function testWaitDeprecatedFunction(): void |
1371 | 1409 | { |
1372 | 1410 | $nativeConnection = $this->getMockBuilder(PDO::class) |
1373 | 1411 | ->disableOriginalConstructor() |
|
0 commit comments