-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow to load different modules * load namespaces condtionally * Event sourcing test scenario * Failing test * add a ValidityCheckPass.php * fix symfony external references aliasing * make it work * fix another missing DefinedObject * cleaning * disabling dbal * clean * add laravel missing directory --------- Co-authored-by: jlabedo <jean@needelp.com>
- Loading branch information
Showing
67 changed files
with
1,574 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Monorepo/CrossModuleTests/Tests/EventSourcingStackTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Monorepo\CrossModuleTests\Tests; | ||
|
||
use Ecotone\Messaging\Config\ConfiguredMessagingSystem; | ||
use Ecotone\Messaging\Config\ModulePackageList; | ||
use Ecotone\Modelling\CommandBus; | ||
use Ecotone\Modelling\QueryBus; | ||
use Illuminate\Foundation\Http\Kernel as LaravelKernel; | ||
use Monorepo\ExampleAppEventSourcing\Common\Command\ChangePrice; | ||
use Monorepo\ExampleAppEventSourcing\Common\Command\RegisterProduct; | ||
use Monorepo\ExampleAppEventSourcing\Common\PriceChange; | ||
use Monorepo\ExampleAppEventSourcing\ExampleAppEventSourcingCaseTrait; | ||
use Monorepo\ExampleAppEventSourcing\Symfony\Kernel; | ||
use Monorepo\ExampleAppEventSourcing\Symfony\Kernel as SymfonyKernel; | ||
use PHPUnit\Framework\Assert; | ||
use Psr\Container\ContainerInterface; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
final class EventSourcingStackTest extends FullAppTestCase | ||
{ | ||
use ExampleAppEventSourcingCaseTrait; | ||
|
||
public static function skippedPackages(): array | ||
{ | ||
return ModulePackageList::allPackagesExcept([ | ||
ModulePackageList::EVENT_SOURCING_PACKAGE, | ||
// @TODO uncomment to fail on dbal configuration | ||
// @dgafka: it is required to register "Enqueue\Dbal\DbalConnectionFactory" when using dbal, or you will get a compile time error | ||
// ModulePackageList::DBAL_PACKAGE, | ||
ModulePackageList::JMS_CONVERTER_PACKAGE | ||
]); | ||
} | ||
|
||
public static function namespacesToLoad(): array | ||
{ | ||
return ['Monorepo\ExampleApp\CommonEventSourcing']; | ||
} | ||
|
||
public function executeForSymfony(ContainerInterface $container, \Symfony\Component\HttpKernel\Kernel $kernel): void | ||
{ | ||
$this->executeTestScenario( | ||
$container->get(CommandBus::class), | ||
$container->get(QueryBus::class) | ||
); | ||
} | ||
|
||
private function executeTestScenario(CommandBus $commandBus, QueryBus $queryBus): void | ||
{ | ||
$productId = Uuid::uuid4()->toString(); | ||
$commandBus->send(new RegisterProduct($productId, 100)); | ||
|
||
Assert::assertEquals([new PriceChange(100, 0)], $queryBus->sendWithRouting('product.getPriceChange', $productId), 'Price change should equal to 0 after registration'); | ||
|
||
$commandBus->send(new ChangePrice($productId, 120)); | ||
|
||
Assert::assertEquals([new PriceChange(100, 0), new PriceChange(120, 20)], $queryBus->sendWithRouting('product.getPriceChange', $productId), 'Price change should equal to 0 after registration'); | ||
} | ||
|
||
public function executeForLaravel(ContainerInterface $container, LaravelKernel $kernel): void | ||
{ | ||
$this->executeTestScenario( | ||
$container->get(CommandBus::class), | ||
$container->get(QueryBus::class) | ||
); | ||
} | ||
|
||
public function executeForLiteApplication(ContainerInterface $container): void | ||
{ | ||
$this->executeTestScenario( | ||
$container->get(CommandBus::class), | ||
$container->get(QueryBus::class) | ||
); | ||
} | ||
|
||
public function executeForLite(ConfiguredMessagingSystem $messagingSystem): void | ||
{ | ||
$this->executeTestScenario( | ||
$messagingSystem->getCommandBus(), | ||
$messagingSystem->getQueryBus() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.