|
38 | 38 | use Patchlevel\EventSourcing\Projection\Projectionist\SyncProjectionistEventBusWrapper; |
39 | 39 | use Patchlevel\EventSourcing\Projection\Projectionist\DefaultProjectionist; |
40 | 40 | use Patchlevel\EventSourcing\Projection\Projectionist\Projectionist; |
| 41 | +use Patchlevel\EventSourcing\Projection\Projector\ProjectorRepository; |
41 | 42 | use Patchlevel\EventSourcing\Repository\DefaultRepository; |
42 | 43 | use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager; |
43 | 44 | use Patchlevel\EventSourcing\Repository\RepositoryManager; |
|
62 | 63 | use Patchlevel\EventSourcingBundle\Tests\Fixtures\Processor2; |
63 | 64 | use Patchlevel\EventSourcingBundle\Tests\Fixtures\Profile; |
64 | 65 | use Patchlevel\EventSourcingBundle\Tests\Fixtures\ProfileCreated; |
| 66 | +use Patchlevel\EventSourcingBundle\Tests\Fixtures\ProfileProjector; |
65 | 67 | use Patchlevel\EventSourcingBundle\Tests\Fixtures\SnapshotableProfile; |
66 | 68 | use PHPUnit\Framework\TestCase; |
67 | 69 | use Prophecy\PhpUnit\ProphecyTrait; |
@@ -202,6 +204,43 @@ public function testProcessorListener(): void |
202 | 204 | ); |
203 | 205 | } |
204 | 206 |
|
| 207 | + |
| 208 | + public function testAutoconfigureProcessorListener(): void |
| 209 | + { |
| 210 | + $container = new ContainerBuilder(); |
| 211 | + $container->setDefinition(Processor1::class, new Definition(Processor1::class)) |
| 212 | + ->setAutoconfigured(true); |
| 213 | + $container->setDefinition(Processor2::class, new Definition(Processor1::class)) |
| 214 | + ->setAutoconfigured(false); |
| 215 | + |
| 216 | + $this->compileContainer( |
| 217 | + $container, |
| 218 | + [ |
| 219 | + 'patchlevel_event_sourcing' => [ |
| 220 | + 'connection' => [ |
| 221 | + 'service' => 'doctrine.dbal.eventstore_connection', |
| 222 | + ], |
| 223 | + 'projection' => [ |
| 224 | + 'sync' => false, |
| 225 | + ], |
| 226 | + ], |
| 227 | + ] |
| 228 | + ); |
| 229 | + |
| 230 | + self::assertInstanceOf(DefaultEventBus::class, $container->get(EventBus::class)); |
| 231 | + self::assertEquals( |
| 232 | + [ |
| 233 | + 'Patchlevel\EventSourcingBundle\Tests\Fixtures\Processor1' => [ |
| 234 | + [], |
| 235 | + ], |
| 236 | + 'Patchlevel\EventSourcingBundle\DataCollector\MessageListener' => [ |
| 237 | + [] |
| 238 | + ] |
| 239 | + ], |
| 240 | + $container->findTaggedServiceIds('event_sourcing.processor') |
| 241 | + ); |
| 242 | + } |
| 243 | + |
205 | 244 | public function testSymfonyEventBus(): void |
206 | 245 | { |
207 | 246 | $container = new ContainerBuilder(); |
@@ -710,6 +749,30 @@ public function testProjectionistAutoBoot(): void |
710 | 749 | self::assertInstanceOf(ProjectionistAutoBootListener::class, $container->get(ProjectionistAutoBootListener::class)); |
711 | 750 | } |
712 | 751 |
|
| 752 | + public function testAutoconfigureProjector(): void |
| 753 | + { |
| 754 | + $container = new ContainerBuilder(); |
| 755 | + $container->setDefinition(ProfileProjector::class, new Definition(ProfileProjector::class)) |
| 756 | + ->setAutoconfigured(true); |
| 757 | + |
| 758 | + $this->compileContainer( |
| 759 | + $container, |
| 760 | + [ |
| 761 | + 'patchlevel_event_sourcing' => [ |
| 762 | + 'connection' => [ |
| 763 | + 'service' => 'doctrine.dbal.eventstore_connection', |
| 764 | + ], |
| 765 | + ], |
| 766 | + ] |
| 767 | + ); |
| 768 | + |
| 769 | + $repository = $container->get(ProjectorRepository::class); |
| 770 | + $projectors = $repository->projectors(); |
| 771 | + |
| 772 | + self::assertCount(1, $projectors); |
| 773 | + self::assertInstanceOf(ProfileProjector::class, $projectors[0]); |
| 774 | + } |
| 775 | + |
713 | 776 | public function testSchemaMerge(): void |
714 | 777 | { |
715 | 778 | $container = new ContainerBuilder(); |
|
0 commit comments