|
6 | 6 |
|
7 | 7 | use DateTimeImmutable; |
8 | 8 | use Doctrine\DBAL\Connection; |
| 9 | +use Doctrine\DBAL\Schema\Schema; |
9 | 10 | use Patchlevel\EventSourcing\Clock\FrozenClock; |
10 | 11 | use Patchlevel\EventSourcing\Message\Message; |
11 | 12 | use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector; |
@@ -538,4 +539,40 @@ public function testRemove(): void |
538 | 539 |
|
539 | 540 | self::assertEquals(['foo'], $streams); |
540 | 541 | } |
| 542 | + |
| 543 | + public function testConfigureSchemaSameDatabase(): void |
| 544 | + { |
| 545 | + $connection = DbalManager::createConnection(); |
| 546 | + $otherConnection = DbalManager::createConnection(); |
| 547 | + |
| 548 | + $store = new StreamDoctrineDbalStore( |
| 549 | + $connection, |
| 550 | + DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), |
| 551 | + clock: $this->clock, |
| 552 | + ); |
| 553 | + |
| 554 | + $schema = new Schema(); |
| 555 | + |
| 556 | + $store->configureSchema($schema, $otherConnection); |
| 557 | + |
| 558 | + self::assertTrue($schema->hasTable('event_store')); |
| 559 | + } |
| 560 | + |
| 561 | + public function testConfigureSchemaNotSameDatabase(): void |
| 562 | + { |
| 563 | + $connection = DbalManager::createConnection(); |
| 564 | + $otherConnection = DbalManager::createConnection('other'); |
| 565 | + |
| 566 | + $store = new StreamDoctrineDbalStore( |
| 567 | + $connection, |
| 568 | + DefaultEventSerializer::createFromPaths([__DIR__ . '/Events']), |
| 569 | + clock: $this->clock, |
| 570 | + ); |
| 571 | + |
| 572 | + $schema = new Schema(); |
| 573 | + |
| 574 | + $store->configureSchema($schema, $otherConnection); |
| 575 | + |
| 576 | + self::assertFalse($schema->hasTable('event_store')); |
| 577 | + } |
541 | 578 | } |
0 commit comments