|
10 | 10 | use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand; |
11 | 11 | use Doctrine\Migrations\Tools\Console\Command\MigrateCommand; |
12 | 12 | use Doctrine\Migrations\Tools\Console\Command\StatusCommand; |
| 13 | +use Doctrine\Persistence\ManagerRegistry; |
13 | 14 | use InvalidArgumentException; |
14 | 15 | use Patchlevel\EventSourcing\Attribute\Aggregate; |
15 | 16 | use Patchlevel\EventSourcing\Attribute\Event; |
|
26 | 27 | use Patchlevel\EventSourcing\Console\Command\SchemaUpdateCommand; |
27 | 28 | use Patchlevel\EventSourcing\Console\Command\ShowAggregateCommand; |
28 | 29 | use Patchlevel\EventSourcing\Console\Command\ShowCommand; |
| 30 | +use Patchlevel\EventSourcing\Console\Command\StoreMigrateCommand; |
29 | 31 | use Patchlevel\EventSourcing\Console\Command\SubscriptionBootCommand; |
30 | 32 | use Patchlevel\EventSourcing\Console\Command\SubscriptionPauseCommand; |
31 | 33 | use Patchlevel\EventSourcing\Console\Command\SubscriptionReactivateCommand; |
| 34 | +use Patchlevel\EventSourcing\Console\Command\SubscriptionRefreshCommand; |
32 | 35 | use Patchlevel\EventSourcing\Console\Command\SubscriptionRemoveCommand; |
33 | 36 | use Patchlevel\EventSourcing\Console\Command\SubscriptionRunCommand; |
34 | 37 | use Patchlevel\EventSourcing\Console\Command\SubscriptionSetupCommand; |
|
67 | 70 | use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore; |
68 | 71 | use Patchlevel\EventSourcing\Store\StreamReadOnlyStore; |
69 | 72 | use Patchlevel\EventSourcing\Store\StreamStore; |
| 73 | +use Patchlevel\EventSourcing\Subscription\Cleanup\Cleaner; |
| 74 | +use Patchlevel\EventSourcing\Subscription\Cleanup\Dbal\DbalCleanupTaskHandler; |
| 75 | +use Patchlevel\EventSourcing\Subscription\Cleanup\DefaultCleaner; |
70 | 76 | use Patchlevel\EventSourcing\Subscription\Engine\CatchUpSubscriptionEngine; |
71 | 77 | use Patchlevel\EventSourcing\Subscription\Engine\DefaultSubscriptionEngine; |
72 | 78 | use Patchlevel\EventSourcing\Subscription\Engine\GapResolverStoreMessageLoader; |
|
82 | 88 | use Patchlevel\EventSourcing\Subscription\Store\InMemorySubscriptionStore; |
83 | 89 | use Patchlevel\EventSourcing\Subscription\Store\SubscriptionStore; |
84 | 90 | use Patchlevel\EventSourcing\Subscription\Subscriber\MetadataSubscriberAccessorRepository; |
85 | | -use Patchlevel\EventSourcingBundle\Command\StoreMigrateCommand; |
86 | | -use Patchlevel\EventSourcingBundle\DependencyInjection\Configuration; |
87 | 91 | use Patchlevel\EventSourcingBundle\DependencyInjection\PatchlevelEventSourcingExtension; |
88 | 92 | use Patchlevel\EventSourcingBundle\EventBus\SymfonyEventBus; |
89 | 93 | use Patchlevel\EventSourcingBundle\PatchlevelEventSourcingBundle; |
@@ -786,6 +790,60 @@ public function testGapDetectionWithExplicitValues(): void |
786 | 790 | self::assertInstanceOf(GapResolverStoreMessageLoader::class, $messageLoader); |
787 | 791 | } |
788 | 792 |
|
| 793 | + public function testSubscriptionCleanupWithDoctrine(): void |
| 794 | + { |
| 795 | + $registry = $this->createMock(ManagerRegistry::class); |
| 796 | + |
| 797 | + $container = new ContainerBuilder(); |
| 798 | + $container->set('doctrine', $registry); |
| 799 | + |
| 800 | + $this->compileContainer( |
| 801 | + $container, |
| 802 | + [ |
| 803 | + 'patchlevel_event_sourcing' => [ |
| 804 | + 'connection' => [ |
| 805 | + 'service' => 'doctrine.dbal.eventstore_connection', |
| 806 | + ], |
| 807 | + 'store' => [ |
| 808 | + 'merge_orm_schema' => true, |
| 809 | + ], |
| 810 | + ], |
| 811 | + ] |
| 812 | + ); |
| 813 | + |
| 814 | + $definition = $container->getDefinition(DbalCleanupTaskHandler::class); |
| 815 | + $tags = $definition->getTag('event_sourcing.cleanup_task_handler'); |
| 816 | + |
| 817 | + self::assertCount(1, $tags); |
| 818 | + |
| 819 | + $cleaner = $container->get(Cleaner::class); |
| 820 | + self::assertInstanceOf(DefaultCleaner::class, $cleaner); |
| 821 | + } |
| 822 | + |
| 823 | + public function testSubscriptionCleanupWithProjectionConnection(): void |
| 824 | + { |
| 825 | + $container = new ContainerBuilder(); |
| 826 | + $this->compileContainer( |
| 827 | + $container, |
| 828 | + [ |
| 829 | + 'patchlevel_event_sourcing' => [ |
| 830 | + 'connection' => [ |
| 831 | + 'url' => 'sqlite3:///:memory:', |
| 832 | + 'provide_dedicated_connection' => true, |
| 833 | + ], |
| 834 | + ], |
| 835 | + ] |
| 836 | + ); |
| 837 | + |
| 838 | + $definition = $container->getDefinition(DbalCleanupTaskHandler::class); |
| 839 | + $tags = $definition->getTag('event_sourcing.cleanup_task_handler'); |
| 840 | + |
| 841 | + self::assertCount(1, $tags); |
| 842 | + |
| 843 | + $cleaner = $container->get(Cleaner::class); |
| 844 | + self::assertInstanceOf(DefaultCleaner::class, $cleaner); |
| 845 | + } |
| 846 | + |
789 | 847 | public function testSnapshotStore(): void |
790 | 848 | { |
791 | 849 | $container = new ContainerBuilder(); |
@@ -1013,6 +1071,7 @@ public function testCommands(): void |
1013 | 1071 | self::assertInstanceOf(SubscriptionSetupCommand::class, $container->get(SubscriptionSetupCommand::class)); |
1014 | 1072 | self::assertInstanceOf(SubscriptionStatusCommand::class, $container->get(SubscriptionStatusCommand::class)); |
1015 | 1073 | self::assertInstanceOf(SubscriptionTeardownCommand::class, $container->get(SubscriptionTeardownCommand::class)); |
| 1074 | + self::assertInstanceOf(SubscriptionRefreshCommand::class, $container->get(SubscriptionRefreshCommand::class)); |
1016 | 1075 | self::assertInstanceOf(SchemaCreateCommand::class, $container->get(SchemaCreateCommand::class)); |
1017 | 1076 | self::assertInstanceOf(SchemaUpdateCommand::class, $container->get(SchemaUpdateCommand::class)); |
1018 | 1077 | self::assertInstanceOf(SchemaDropCommand::class, $container->get(SchemaDropCommand::class)); |
|
0 commit comments