|
4 | 4 |
|
5 | 5 | namespace Integration; |
6 | 6 |
|
| 7 | +use Ecotone\EventSourcing\Database\EventStreamTableManager; |
7 | 8 | use Ecotone\EventSourcing\EventStore; |
8 | 9 | use Ecotone\EventSourcing\Prooph\LazyProophEventStore; |
9 | 10 | use Ecotone\Lite\EcotoneLite; |
|
14 | 15 | use Enqueue\Dbal\DbalConnectionFactory; |
15 | 16 | use Ramsey\Uuid\Uuid; |
16 | 17 | use Test\Ecotone\EventSourcing\EventSourcingMessagingTestCase; |
| 18 | +use Test\Ecotone\EventSourcing\Fixture\Ticket\Command\RegisterTicket; |
17 | 19 | use Test\Ecotone\EventSourcing\Fixture\Ticket\Event\TicketWasClosed; |
18 | 20 | use Test\Ecotone\EventSourcing\Fixture\Ticket\Event\TicketWasRegistered; |
| 21 | +use Test\Ecotone\EventSourcing\Fixture\Ticket\Ticket; |
19 | 22 | use Test\Ecotone\EventSourcing\Fixture\Ticket\TicketEventConverter; |
20 | 23 | use Test\Ecotone\EventSourcing\Fixture\TicketWithSynchronousEventDrivenProjection\InProgressTicketList; |
21 | 24 |
|
@@ -303,4 +306,38 @@ public function test_fetching_with_pagination() |
303 | 306 | $events[0]->getPayload() |
304 | 307 | ); |
305 | 308 | } |
| 309 | + |
| 310 | + public function test_deleting_event_stream_table_also_deletes_stream_tables(): void |
| 311 | + { |
| 312 | + $ecotone = EcotoneLite::bootstrapFlowTestingWithEventStore( |
| 313 | + containerOrAvailableServices: [ |
| 314 | + new InProgressTicketList($this->getConnection()), |
| 315 | + new TicketEventConverter(), |
| 316 | + DbalConnectionFactory::class => $this->getConnectionFactory(), |
| 317 | + ], |
| 318 | + configuration: ServiceConfiguration::createWithDefaults() |
| 319 | + ->withEnvironment('prod') |
| 320 | + ->withSkippedModulePackageNames(ModulePackageList::allPackagesExcept([ModulePackageList::EVENT_SOURCING_PACKAGE])) |
| 321 | + ->withNamespaces([ |
| 322 | + 'Test\Ecotone\EventSourcing\Fixture\Ticket', |
| 323 | + ]), |
| 324 | + pathToRootCatalog: __DIR__ . '/../../', |
| 325 | + runForProductionEventStore: true |
| 326 | + ); |
| 327 | + |
| 328 | + $ecotone->sendCommand(new RegisterTicket('1', 'johny', 'alert')); |
| 329 | + |
| 330 | + $connection = $this->getConnection(); |
| 331 | + $eventStreamsTable = LazyProophEventStore::DEFAULT_STREAM_TABLE; |
| 332 | + $streamTableName = '_' . sha1(Ticket::class); |
| 333 | + |
| 334 | + $this->assertTrue(self::tableExists($connection, $eventStreamsTable)); |
| 335 | + $this->assertTrue(self::tableExists($connection, $streamTableName)); |
| 336 | + |
| 337 | + $tableManager = new EventStreamTableManager($eventStreamsTable, true, true); |
| 338 | + $tableManager->dropTable($connection); |
| 339 | + |
| 340 | + $this->assertFalse(self::tableExists($connection, $streamTableName)); |
| 341 | + $this->assertFalse(self::tableExists($connection, $eventStreamsTable)); |
| 342 | + } |
306 | 343 | } |
0 commit comments