diff --git a/packages/PdoEventSourcing/src/Config/EventSourcingModule.php b/packages/PdoEventSourcing/src/Config/EventSourcingModule.php index 974d8738b..71f7d1a13 100644 --- a/packages/PdoEventSourcing/src/Config/EventSourcingModule.php +++ b/packages/PdoEventSourcing/src/Config/EventSourcingModule.php @@ -564,7 +564,7 @@ private function registerProjections(ServiceConfiguration $serviceConfiguration, ->withEndpointId($projectionSetupConfiguration->getProjectionName()) ); - return; + continue; } /** Projection will be called sync or async triggered by Event Bus. In that case we need to connect them to event related channels */ diff --git a/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/Products.php b/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/Products.php new file mode 100644 index 000000000..cc76f48d4 --- /dev/null +++ b/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/Products.php @@ -0,0 +1,33 @@ +getProductName(), $this->products)) { + ++$this->products[$event->getProductName()]; + } + $this->products[$event->getProductName()] = 1; + } + + #[QueryHandler('getALlProducts')] + public function getAllProducts(): array + { + return $this->products; + } +} diff --git a/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/ProductsConfiguration.php b/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/ProductsConfiguration.php new file mode 100644 index 000000000..6b22c6851 --- /dev/null +++ b/packages/PdoEventSourcing/tests/Fixture/ProductsProjection/ProductsConfiguration.php @@ -0,0 +1,26 @@ +setExecutionAmountLimit(3) + ->setExecutionTimeLimitInMilliseconds(300); + } + + #[ServiceContext] + public function enablePollingProjection(): ProjectionRunningConfiguration + { + return ProjectionRunningConfiguration::createPolling(Products::PROJECTION_NAME); + } +} diff --git a/packages/PdoEventSourcing/tests/Integration/PollingProjectionTest.php b/packages/PdoEventSourcing/tests/Integration/PollingProjectionTest.php index 05337795b..fad9b2834 100644 --- a/packages/PdoEventSourcing/tests/Integration/PollingProjectionTest.php +++ b/packages/PdoEventSourcing/tests/Integration/PollingProjectionTest.php @@ -7,21 +7,22 @@ use Ecotone\Lite\EcotoneLite; use Ecotone\Messaging\Config\ServiceConfiguration; use Ecotone\Messaging\Endpoint\ExecutionPollingMetadata; -use Ecotone\Messaging\Endpoint\PollingMetadata; use PHPUnit\Framework\TestCase; use Test\Ecotone\EventSourcing\Fixture\Basket\BasketEventConverter; use Test\Ecotone\EventSourcing\Fixture\Basket\Command\AddProduct; use Test\Ecotone\EventSourcing\Fixture\Basket\Command\CreateBasket; use Test\Ecotone\EventSourcing\Fixture\BasketListProjection\BasketList; use Test\Ecotone\EventSourcing\Fixture\BasketListProjection\BasketListConfiguration; +use Test\Ecotone\EventSourcing\Fixture\ProductsProjection\Products; +use Test\Ecotone\EventSourcing\Fixture\ProductsProjection\ProductsConfiguration; final class PollingProjectionTest extends TestCase { public function test_running_polling_projection(): void { $ecotoneLite = EcotoneLite::bootstrapFlowTestingWithEventStore( - classesToResolve: [BasketListConfiguration::class, BasketList::class], - containerOrAvailableServices: [new BasketList(), new BasketEventConverter()], + classesToResolve: [BasketListConfiguration::class, BasketList::class, ProductsConfiguration::class, Products::class], + containerOrAvailableServices: [new BasketList(), new Products(), new BasketEventConverter()], configuration: ServiceConfiguration::createWithDefaults() ->withNamespaces(['Test\Ecotone\EventSourcing\Fixture\Basket']), pathToRootCatalog: __DIR__ . '/../../' @@ -31,10 +32,14 @@ classesToResolve: [BasketListConfiguration::class, BasketList::class], $ecotoneLite->run(BasketList::PROJECTION_NAME, ExecutionPollingMetadata::createWithTestingSetup(maxExecutionTimeInMilliseconds: 1000)); self::assertEquals(['1000' => []], $ecotoneLite->sendQueryWithRouting('getALlBaskets')); + self::assertEquals([], $ecotoneLite->sendQueryWithRouting('getALlProducts')); $ecotoneLite->sendCommand(new AddProduct('1000', 'milk')); + $ecotoneLite->run(BasketList::PROJECTION_NAME, ExecutionPollingMetadata::createWithTestingSetup(maxExecutionTimeInMilliseconds: 1000)); + $ecotoneLite->run(Products::PROJECTION_NAME, ExecutionPollingMetadata::createWithTestingSetup(maxExecutionTimeInMilliseconds: 1000)); self::assertEquals(['1000' => ['milk']], $ecotoneLite->sendQueryWithRouting('getALlBaskets')); + self::assertEquals(['milk' => 1], $ecotoneLite->sendQueryWithRouting('getALlProducts')); } }