diff --git a/baseline.xml b/baseline.xml
index 4d93581e..ee9846ac 100644
--- a/baseline.xml
+++ b/baseline.xml
@@ -10,49 +10,12 @@
$sleep
-
-
- MetadataAwareProjectionHandler
- MetadataAwareProjectionHandler::class
- Projection
- ProjectionHandler
- ProjectionHandler
- ProjectionHandler
- ProjectionHandler
- non-empty-array<class-string<Projection>>
- non-empty-array<class-string<Projection>>|null
-
-
-
-
- ProjectionHandler
- new ProjectionHandlerTarget($projectionHandler)
-
-
$messageLimit
$sleep
-
-
- SchemaManager|SchemaDirector
- SchemaManager|SchemaDirector $schemaDirector
-
-
-
-
- SchemaManager|SchemaDirector
- SchemaManager|SchemaDirector $schemaDirector
-
-
-
-
- SchemaManager|SchemaDirector
- SchemaManager|SchemaDirector $schemaDirector
-
-
class DoctrineHelper
@@ -76,81 +39,6 @@
Headers
-
-
- array
- class-string<Projection>
- private array $projectionMetadata = [];
-
-
-
-
- class-string<Projection>
-
-
-
-
- class-string<Projection>
-
-
-
-
- class-string<Projection>
-
-
-
-
- class-string<Projection>
-
-
-
-
- PipelineStore
- PipelineStore
-
-
-
-
- ProjectionHandler
- ProjectionHandler
-
-
-
-
- MetadataAwareProjectionHandler
- Projection
-
-
-
-
- iterable
- iterable<Projection>
- iterable<Projection>
-
-
- MetadataAwareProjectionHandler
-
-
-
-
- ProjectionHandler
- ProjectionHandler
-
-
-
-
- Projection
- Projection
- Projection
-
-
-
-
- Projection
- Projection
- Projection
-
-
$messages[0]->playhead() - 1
@@ -172,32 +60,6 @@
toSql
-
-
- new StoreNotSupported($store, DoctrineStore::class)
- new StoreNotSupported($store, DoctrineStore::class)
- new StoreNotSupported($store, DoctrineStore::class)
- new StoreNotSupported($store, DoctrineStore::class)
- new StoreNotSupported($store, DoctrineStore::class)
- new StoreNotSupported($store, DoctrineStore::class)
-
-
- DoctrineSchemaManager
-
-
- createSchema
- createSchema
- schema
- schema
- schema
- toSql
-
-
-
-
- schema
-
-
$payload[$key]
@@ -215,23 +77,10 @@
-
- MultiTableStore
-
array{id: string, aggregate_id: string, playhead: string, event: string, payload: string, recorded_on: string, custom_headers: string}|null
-
-
- SingleTableStore
-
-
-
-
- ProfileProjector
-
-
$bus
@@ -248,9 +97,6 @@
-
- new ProjectionListener($projectionRepository)
-
$bus
$profile
@@ -258,80 +104,35 @@
$store
-
-
- new MetadataAwareProjectionHandler([$bankAccountProjection])
- new MetadataAwareProjectionHandler([$bankAccountProjection])
- new ProjectionListener($projectionRepository)
- new ProjectionListener($projectionRepository)
-
-
-
- BankAccountProjection
-
toString
toString
-
-
- ProfileProjection
-
-
-
-
- new ProjectionListener($projectionRepository)
-
-
-
- ProfileProjection
-
toString
-
-
- ProfileProjection
-
-
-
-
- $this->prophesize(ProjectionHandler::class)
- new MetadataAwareProjectionHandler([$projectionA, $projectionB])
-
-
-
- $this->prophesize(ProjectionHandler::class)
- new MetadataAwareProjectionHandler([$projectionA, $projectionB])
-
+
+ $repository->reveal()
+
+
+ ProjectionHandler::class
+
+
+ ProjectionHandler
+
-
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
- $this->prophesize(ProjectionHandler::class)
- $this->prophesize(ProjectionHandler::class)
- $this->prophesize(ProjectionHandler::class)
- new MetadataAwareProjectionHandler([$projectionA, $projectionB])
- new MetadataAwareProjectionHandler([$projectionA, $projectionB])
-
-
-
-
- Dummy2Projection
-
-
-
-
- DummyProjection
-
+
+ $store->reveal()
+ $store->reveal()
+ $store->reveal()
+ $store->reveal()
+
@@ -343,143 +144,10 @@
$event
-
-
- class implements Projection {
- class implements Projection {
- class implements Projection {
- class implements Projection {
- class implements Projection {
-
-
-
-
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
- $this->prophesize(PipelineStore::class)
-
-
-
-
- $this->prophesize(ProjectionHandler::class)
- new ProjectionHandlerTarget($projectionHandler->reveal())
-
-
-
-
- new ProjectionTarget($projection)
-
-
- class implements Projection {
-
-
-
-
- $this->prophesize(PipelineStore::class)
-
-
-
-
- new MetadataAwareProjectionHandler([$projection])
- new MetadataAwareProjectionHandler([$projection])
- new MetadataAwareProjectionHandler([$projection])
- new MetadataAwareProjectionHandler([$projection])
- new MetadataAwareProjectionHandler([])
-
-
- class implements Projection {
- class implements Projection {
- class implements Projection {
- class implements Projection {
-
-
-
-
- $this->prophesize(ProjectionHandler::class)
- new ProjectionListener($projectionRepository->reveal())
-
-
-
-
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
- class implements VersionedProjector {
-
-
-
-
- class implements Projector {
-
-
-
-
- class implements Projector {
- class implements Projector {
- class implements Projector {
- class implements Projector {
- class implements Projector {
- class implements Projector {
-
-
-
-
- class implements Projector {
- class implements Projector {
- class implements Projector {
- class implements Projector {
-
-
-
-
- class implements Projector {
- class implements Projector {
-
-
new Comparator()
new Comparator()
-
-
- StoreNotSupported::class
- StoreNotSupported::class
- StoreNotSupported::class
- StoreNotSupported::class
- StoreNotSupported::class
- StoreNotSupported::class
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
- new DoctrineSchemaManager()
-
-
-
-
- new MigrationSchemaProvider($store->reveal())
-
-
diff --git a/src/Console/Command/ProjectionCommand.php b/src/Console/Command/ProjectionCommand.php
index 0565d4db..0eb9b623 100644
--- a/src/Console/Command/ProjectionCommand.php
+++ b/src/Console/Command/ProjectionCommand.php
@@ -4,11 +4,9 @@
namespace Patchlevel\EventSourcing\Console\Command;
-use InvalidArgumentException;
use Patchlevel\EventSourcing\Console\InvalidArgumentGiven;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\Projection;
-use Patchlevel\EventSourcing\Projection\ProjectionHandler;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorRepository;
use Symfony\Component\Console\Command\Command;
use function array_filter;
@@ -17,35 +15,39 @@
use function is_array;
use function is_string;
use function is_subclass_of;
-use function sprintf;
abstract class ProjectionCommand extends Command
{
- private ProjectionHandler $projectionHandler;
+ private readonly ProjectorRepository $projectorRepository;
- public function __construct(ProjectionHandler $projectionHandler)
+ public function __construct(ProjectorRepository $projectorRepository)
{
parent::__construct();
- $this->projectionHandler = $projectionHandler;
+ $this->projectorRepository = $projectorRepository;
}
- protected function projectionHandler(mixed $projectionOption): ProjectionHandler
+ /**
+ * @return list
+ */
+ protected function projectors(mixed $projectionOption): array
{
$normalizedProjectionOption = $this->normalizeProjectionOption($projectionOption);
if (!$normalizedProjectionOption) {
- return $this->projectionHandler;
+ return $this->projectorRepository->projectors();
}
- return $this->filterProjectionInProjectionHandler(
- $this->projectionHandler,
- $normalizedProjectionOption
+ return array_values(
+ array_filter(
+ [...$this->projectorRepository->projectors()],
+ static fn (Projector $projection): bool => in_array($projection::class, $normalizedProjectionOption)
+ )
);
}
/**
- * @return non-empty-array>|null
+ * @return non-empty-array>|null
*/
private function normalizeProjectionOption(mixed $option): ?array
{
@@ -54,14 +56,14 @@ private function normalizeProjectionOption(mixed $option): ?array
}
if (!is_array($option)) {
- throw new InvalidArgumentGiven($option, 'class-string<' . Projection::class . '>[]');
+ throw new InvalidArgumentGiven($option, 'class-string<' . Projector::class . '>[]');
}
$result = [];
foreach ($option as $entry) {
- if (!is_string($entry) || !is_subclass_of($entry, Projection::class)) {
- throw new InvalidArgumentGiven($entry, 'class-string<' . Projection::class . '>');
+ if (!is_string($entry) || !is_subclass_of($entry, Projector::class)) {
+ throw new InvalidArgumentGiven($entry, 'class-string<' . Projector::class . '>');
}
$result[] = $entry;
@@ -73,34 +75,4 @@ private function normalizeProjectionOption(mixed $option): ?array
return $result;
}
-
- /**
- * @param non-empty-array> $onlyProjections
- */
- private function filterProjectionInProjectionHandler(
- ProjectionHandler $projectionHandler,
- array $onlyProjections
- ): MetadataAwareProjectionHandler {
- if (!$projectionHandler instanceof MetadataAwareProjectionHandler) {
- throw new InvalidArgumentException(
- sprintf(
- 'Filtering projections is only supported with "%s", but "%s" was used.',
- MetadataAwareProjectionHandler::class,
- $projectionHandler::class
- )
- );
- }
-
- $projections = array_values(
- array_filter(
- [...$projectionHandler->projections()],
- static fn (Projection $projection): bool => in_array($projection::class, $onlyProjections)
- )
- );
-
- return new MetadataAwareProjectionHandler(
- $projections,
- $projectionHandler->metadataFactory()
- );
- }
}
diff --git a/src/Console/Command/ProjectionCreateCommand.php b/src/Console/Command/ProjectionCreateCommand.php
index ed61afee..c5980cf8 100644
--- a/src/Console/Command/ProjectionCreateCommand.php
+++ b/src/Console/Command/ProjectionCreateCommand.php
@@ -5,6 +5,10 @@
namespace Patchlevel\EventSourcing\Console\Command;
use Patchlevel\EventSourcing\Console\OutputStyle;
+use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorHelper;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorResolver;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -16,6 +20,17 @@
)]
final class ProjectionCreateCommand extends ProjectionCommand
{
+ private readonly ProjectorResolver $projectorResolver;
+
+ public function __construct(
+ ProjectorRepository $projectorRepository,
+ ProjectorResolver $projectorResolver = new MetadataProjectorResolver()
+ ) {
+ parent::__construct($projectorRepository);
+
+ $this->projectorResolver = $projectorResolver;
+ }
+
protected function configure(): void
{
$this
@@ -26,7 +41,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$console = new OutputStyle($input, $output);
- $this->projectionHandler($input->getOption('projection'))->create();
+ (new ProjectorHelper($this->projectorResolver))->createProjection(
+ ...$this->projectors(
+ $input->getOption('projection')
+ )
+ );
$console->success('projection created');
diff --git a/src/Console/Command/ProjectionDropCommand.php b/src/Console/Command/ProjectionDropCommand.php
index e4a866c8..addfde5e 100644
--- a/src/Console/Command/ProjectionDropCommand.php
+++ b/src/Console/Command/ProjectionDropCommand.php
@@ -5,6 +5,10 @@
namespace Patchlevel\EventSourcing\Console\Command;
use Patchlevel\EventSourcing\Console\OutputStyle;
+use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorHelper;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorResolver;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -16,6 +20,17 @@
)]
final class ProjectionDropCommand extends ProjectionCommand
{
+ private readonly ProjectorResolver $projectorResolver;
+
+ public function __construct(
+ ProjectorRepository $projectorRepository,
+ ProjectorResolver $projectorResolver = new MetadataProjectorResolver()
+ ) {
+ parent::__construct($projectorRepository);
+
+ $this->projectorResolver = $projectorResolver;
+ }
+
protected function configure(): void
{
$this
@@ -26,7 +41,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$console = new OutputStyle($input, $output);
- $this->projectionHandler($input->getOption('projection'))->drop();
+ (new ProjectorHelper($this->projectorResolver))->dropProjection(
+ ...$this->projectors(
+ $input->getOption('projection')
+ )
+ );
$console->success('projection deleted');
diff --git a/src/Console/Command/ProjectionRebuildCommand.php b/src/Console/Command/ProjectionRebuildCommand.php
index b749f832..d8e4d910 100644
--- a/src/Console/Command/ProjectionRebuildCommand.php
+++ b/src/Console/Command/ProjectionRebuildCommand.php
@@ -10,10 +10,13 @@
use Patchlevel\EventSourcing\Pipeline\Middleware\UntilEventMiddleware;
use Patchlevel\EventSourcing\Pipeline\Pipeline;
use Patchlevel\EventSourcing\Pipeline\Source\StoreSource;
-use Patchlevel\EventSourcing\Pipeline\Target\ProjectionHandlerTarget;
-use Patchlevel\EventSourcing\Projection\ProjectionHandler;
-use Patchlevel\EventSourcing\Store\PipelineStore;
-use Patchlevel\EventSourcing\Store\Store;
+use Patchlevel\EventSourcing\Pipeline\Target\ProjectorRepositoryTarget;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\MetadataProjectorResolver;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorHelper;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\ProjectorResolver;
+use Patchlevel\EventSourcing\Store\StreamableStore;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -29,42 +32,55 @@
)]
final class ProjectionRebuildCommand extends ProjectionCommand
{
- private Store $store;
+ private StreamableStore $store;
+ private ProjectorResolver $projectorResolver;
- public function __construct(Store $store, ProjectionHandler $projectionHandler)
- {
- parent::__construct($projectionHandler);
+ public function __construct(
+ StreamableStore $store,
+ ProjectorRepository $projectorRepository,
+ ProjectorResolver $projectorResolver = new MetadataProjectorResolver()
+ ) {
+ parent::__construct($projectorRepository);
$this->store = $store;
+ $this->projectorResolver = $projectorResolver;
}
protected function configure(): void
{
$this
->addOption('recreate', 'r', InputOption::VALUE_NONE, 'drop and create projections')
- ->addOption('until', 'u', InputOption::VALUE_REQUIRED, 'create the projection up to a point in time [2017-02-02 12:00]')
- ->addOption('projection', 'p', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'run only for specific projections [FQCN]');
+ ->addOption(
+ 'until',
+ 'u',
+ InputOption::VALUE_REQUIRED,
+ 'create the projection up to a point in time [2017-02-02 12:00]'
+ )
+ ->addOption(
+ 'projection',
+ 'p',
+ InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
+ 'run only for specific projections [FQCN]'
+ );
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$console = new OutputStyle($input, $output);
- $store = $this->store;
-
- if (!$store instanceof PipelineStore) {
- $console->error('store is not supported');
-
- return 1;
- }
-
- $projectionHandler = $this->projectionHandler($input->getOption('projection'));
+ $projectors = $this->projectors($input->getOption('projection'));
if (InputHelper::bool($input->getOption('recreate'))) {
- $projectionHandler->drop();
+ (new ProjectorHelper($this->projectorResolver))->dropProjection(
+ ...$projectors
+ );
+
$console->success('projection schema deleted');
- $projectionHandler->create();
+ (new ProjectorHelper($this->projectorResolver))->createProjection(
+ ...$projectors
+ );
+
$console->success('projection schema created');
}
@@ -75,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (is_string($until)) {
try {
$date = new DateTimeImmutable($until);
- } catch (Throwable $exception) {
+ } catch (Throwable) {
$console->error(sprintf('date "%s" not supported. the format should be "2017-02-02 12:00"', $until));
return 1;
@@ -85,8 +101,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$pipeline = new Pipeline(
- new StoreSource($store),
- new ProjectionHandlerTarget($projectionHandler),
+ new StoreSource($this->store),
+ new ProjectorRepositoryTarget(
+ new InMemoryProjectorRepository($projectors),
+ $this->projectorResolver
+ ),
$middlewares
);
diff --git a/src/Console/Command/SchemaCreateCommand.php b/src/Console/Command/SchemaCreateCommand.php
index 5312b740..91be611f 100644
--- a/src/Console/Command/SchemaCreateCommand.php
+++ b/src/Console/Command/SchemaCreateCommand.php
@@ -7,10 +7,7 @@
use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
-use Patchlevel\EventSourcing\Schema\DryRunSchemaManager;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Schema\SchemaManager;
-use Patchlevel\EventSourcing\Store\Store;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -23,14 +20,12 @@
)]
final class SchemaCreateCommand extends Command
{
- private Store $store;
- private SchemaManager|SchemaDirector $schemaDirector;
+ private SchemaDirector $schemaDirector;
- public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector)
+ public function __construct(SchemaDirector $schemaDirector)
{
parent::__construct();
- $this->store = $store;
$this->schemaDirector = $schemaDirector;
}
@@ -47,13 +42,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$dryRun = InputHelper::bool($input->getOption('dry-run'));
if ($dryRun) {
- if (!$this->schemaDirector instanceof DryRunSchemaManager && !$this->schemaDirector instanceof DryRunSchemaDirector) {
+ if (!$this->schemaDirector instanceof DryRunSchemaDirector) {
$console->error('SchemaDirector dont support dry-run');
return 1;
}
- $actions = $this->schemaDirector->dryRunCreate($this->store);
+ $actions = $this->schemaDirector->dryRunCreate();
foreach ($actions as $action) {
$output->writeln($action);
@@ -62,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}
- $this->schemaDirector->create($this->store);
+ $this->schemaDirector->create();
$console->success('schema created');
diff --git a/src/Console/Command/SchemaDropCommand.php b/src/Console/Command/SchemaDropCommand.php
index cc15041e..4f9a00a7 100644
--- a/src/Console/Command/SchemaDropCommand.php
+++ b/src/Console/Command/SchemaDropCommand.php
@@ -7,10 +7,7 @@
use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
-use Patchlevel\EventSourcing\Schema\DryRunSchemaManager;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Schema\SchemaManager;
-use Patchlevel\EventSourcing\Store\Store;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -23,14 +20,12 @@
)]
final class SchemaDropCommand extends Command
{
- private Store $store;
- private SchemaManager|SchemaDirector $schemaDirector;
+ private SchemaDirector $schemaDirector;
- public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector)
+ public function __construct(SchemaDirector $schemaDirector)
{
parent::__construct();
- $this->store = $store;
$this->schemaDirector = $schemaDirector;
}
@@ -47,13 +42,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$dryRun = InputHelper::bool($input->getOption('dry-run'));
if ($dryRun) {
- if (!$this->schemaDirector instanceof DryRunSchemaManager && !$this->schemaDirector instanceof DryRunSchemaDirector) {
+ if (!$this->schemaDirector instanceof DryRunSchemaDirector) {
$console->error('SchemaDirector dont support dry-run');
return 1;
}
- $actions = $this->schemaDirector->dryRunDrop($this->store);
+ $actions = $this->schemaDirector->dryRunDrop();
foreach ($actions as $action) {
$output->writeln($action);
@@ -70,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 1;
}
- $this->schemaDirector->drop($this->store);
+ $this->schemaDirector->drop();
$console->success('schema deleted');
diff --git a/src/Console/Command/SchemaUpdateCommand.php b/src/Console/Command/SchemaUpdateCommand.php
index 16503272..b835fa18 100644
--- a/src/Console/Command/SchemaUpdateCommand.php
+++ b/src/Console/Command/SchemaUpdateCommand.php
@@ -7,10 +7,7 @@
use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
-use Patchlevel\EventSourcing\Schema\DryRunSchemaManager;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Schema\SchemaManager;
-use Patchlevel\EventSourcing\Store\Store;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -23,14 +20,12 @@
)]
final class SchemaUpdateCommand extends Command
{
- private Store $store;
- private SchemaManager|SchemaDirector $schemaDirector;
+ private SchemaDirector $schemaDirector;
- public function __construct(Store $store, SchemaManager|SchemaDirector $schemaDirector)
+ public function __construct(SchemaDirector $schemaDirector)
{
parent::__construct();
- $this->store = $store;
$this->schemaDirector = $schemaDirector;
}
@@ -49,13 +44,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$dryRun = InputHelper::bool($input->getOption('dry-run'));
if ($dryRun) {
- if (!$this->schemaDirector instanceof DryRunSchemaManager && !$this->schemaDirector instanceof DryRunSchemaDirector) {
+ if (!$this->schemaDirector instanceof DryRunSchemaDirector) {
$console->error('SchemaDirector dont support dry-run');
return 1;
}
- $actions = $this->schemaDirector->dryRunUpdate($this->store);
+ $actions = $this->schemaDirector->dryRunUpdate();
foreach ($actions as $action) {
$output->writeln($action);
@@ -72,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 1;
}
- $this->schemaDirector->update($this->store);
+ $this->schemaDirector->update();
$console->success('schema updated');
diff --git a/src/Metadata/Projection/AttributeProjectionMetadataFactory.php b/src/Metadata/Projection/AttributeProjectionMetadataFactory.php
index 90182b81..7ea546bc 100644
--- a/src/Metadata/Projection/AttributeProjectionMetadataFactory.php
+++ b/src/Metadata/Projection/AttributeProjectionMetadataFactory.php
@@ -7,18 +7,18 @@
use Patchlevel\EventSourcing\Attribute\Create;
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Handle;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
use ReflectionClass;
use function array_key_exists;
final class AttributeProjectionMetadataFactory implements ProjectionMetadataFactory
{
- /** @var array, ProjectionMetadata> */
+ /** @var array, ProjectionMetadata> */
private array $projectionMetadata = [];
/**
- * @param class-string $projection
+ * @param class-string $projection
*/
public function metadata(string $projection): ProjectionMetadata
{
diff --git a/src/Metadata/Projection/DuplicateCreateMethod.php b/src/Metadata/Projection/DuplicateCreateMethod.php
index 43f0b060..bc327fe2 100644
--- a/src/Metadata/Projection/DuplicateCreateMethod.php
+++ b/src/Metadata/Projection/DuplicateCreateMethod.php
@@ -5,14 +5,14 @@
namespace Patchlevel\EventSourcing\Metadata\Projection;
use Patchlevel\EventSourcing\Metadata\MetadataException;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
use function sprintf;
final class DuplicateCreateMethod extends MetadataException
{
/**
- * @param class-string $projection
+ * @param class-string $projection
*/
public function __construct(string $projection, string $fistMethod, string $secondMethod)
{
diff --git a/src/Metadata/Projection/DuplicateDropMethod.php b/src/Metadata/Projection/DuplicateDropMethod.php
index 157e0808..45f306c9 100644
--- a/src/Metadata/Projection/DuplicateDropMethod.php
+++ b/src/Metadata/Projection/DuplicateDropMethod.php
@@ -5,14 +5,14 @@
namespace Patchlevel\EventSourcing\Metadata\Projection;
use Patchlevel\EventSourcing\Metadata\MetadataException;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
use function sprintf;
final class DuplicateDropMethod extends MetadataException
{
/**
- * @param class-string $projection
+ * @param class-string $projection
*/
public function __construct(string $projection, string $fistMethod, string $secondMethod)
{
diff --git a/src/Metadata/Projection/DuplicateHandleMethod.php b/src/Metadata/Projection/DuplicateHandleMethod.php
index bb494237..f173e273 100644
--- a/src/Metadata/Projection/DuplicateHandleMethod.php
+++ b/src/Metadata/Projection/DuplicateHandleMethod.php
@@ -5,15 +5,15 @@
namespace Patchlevel\EventSourcing\Metadata\Projection;
use Patchlevel\EventSourcing\Metadata\MetadataException;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
use function sprintf;
final class DuplicateHandleMethod extends MetadataException
{
/**
- * @param class-string $projection
- * @param class-string $event
+ * @param class-string $projection
+ * @param class-string $event
*/
public function __construct(string $projection, string $event, string $fistMethod, string $secondMethod)
{
diff --git a/src/Metadata/Projection/ProjectionMetadataFactory.php b/src/Metadata/Projection/ProjectionMetadataFactory.php
index 41ede493..ed459c1b 100644
--- a/src/Metadata/Projection/ProjectionMetadataFactory.php
+++ b/src/Metadata/Projection/ProjectionMetadataFactory.php
@@ -4,12 +4,12 @@
namespace Patchlevel\EventSourcing\Metadata\Projection;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
interface ProjectionMetadataFactory
{
/**
- * @param class-string $projection
+ * @param class-string $projection
*/
public function metadata(string $projection): ProjectionMetadata;
}
diff --git a/src/Pipeline/Source/StoreSource.php b/src/Pipeline/Source/StoreSource.php
index 2dfd3374..082783a5 100644
--- a/src/Pipeline/Source/StoreSource.php
+++ b/src/Pipeline/Source/StoreSource.php
@@ -6,14 +6,14 @@
use Generator;
use Patchlevel\EventSourcing\EventBus\Message;
-use Patchlevel\EventSourcing\Store\PipelineStore;
+use Patchlevel\EventSourcing\Store\StreamableStore;
final class StoreSource implements Source
{
- private PipelineStore $store;
+ private StreamableStore $store;
private int $fromIndex;
- public function __construct(PipelineStore $store, int $fromIndex = 0)
+ public function __construct(StreamableStore $store, int $fromIndex = 0)
{
$this->store = $store;
$this->fromIndex = $fromIndex;
diff --git a/src/Pipeline/Target/ProjectionHandlerTarget.php b/src/Pipeline/Target/ProjectionHandlerTarget.php
deleted file mode 100644
index 18751ffd..00000000
--- a/src/Pipeline/Target/ProjectionHandlerTarget.php
+++ /dev/null
@@ -1,26 +0,0 @@
-projectionHandler = $projectionHandler;
- }
-
- public function save(Message $message): void
- {
- $this->projectionHandler->handle($message);
- }
-}
diff --git a/src/Pipeline/Target/ProjectionTarget.php b/src/Pipeline/Target/ProjectionTarget.php
deleted file mode 100644
index 8553038d..00000000
--- a/src/Pipeline/Target/ProjectionTarget.php
+++ /dev/null
@@ -1,33 +0,0 @@
-projectionHandler = new MetadataAwareProjectionHandler(
- [$projection],
- $projectionMetadataFactory
- );
- }
-
- public function save(Message $message): void
- {
- $this->projectionHandler->handle($message);
- }
-}
diff --git a/src/Projection/MetadataAwareProjectionHandler.php b/src/Projection/MetadataAwareProjectionHandler.php
deleted file mode 100644
index beb52d65..00000000
--- a/src/Projection/MetadataAwareProjectionHandler.php
+++ /dev/null
@@ -1,86 +0,0 @@
- */
- private iterable $projections;
-
- private ProjectionMetadataFactory $metadataFactory;
-
- private ProjectorResolver $resolver;
-
- /**
- * @param iterable $projections
- */
- public function __construct(iterable $projections, ?ProjectionMetadataFactory $metadataFactory = null)
- {
- $this->projections = $projections;
- $this->metadataFactory = $metadataFactory ?? new AttributeProjectionMetadataFactory();
- $this->resolver = new MetadataProjectorResolver($this->metadataFactory);
- }
-
- public function handle(Message $message): void
- {
- foreach ($this->projections as $projection) {
- $handleMethod = $this->resolver->resolveHandleMethod($projection, $message);
-
- if (!$handleMethod) {
- continue;
- }
-
- $handleMethod($message);
- }
- }
-
- public function create(): void
- {
- foreach ($this->projections as $projection) {
- $createMethod = $this->resolver->resolveCreateMethod($projection);
-
- if (!$createMethod) {
- continue;
- }
-
- $createMethod();
- }
- }
-
- public function drop(): void
- {
- foreach ($this->projections as $projection) {
- $dropMethod = $this->resolver->resolveDropMethod($projection);
-
- if (!$dropMethod) {
- continue;
- }
-
- $dropMethod();
- }
- }
-
- /**
- * @return iterable
- */
- public function projections(): iterable
- {
- return $this->projections;
- }
-
- public function metadataFactory(): ProjectionMetadataFactory
- {
- return $this->metadataFactory;
- }
-}
diff --git a/src/Projection/Projection.php b/src/Projection/Projection.php
deleted file mode 100644
index bdbfbde5..00000000
--- a/src/Projection/Projection.php
+++ /dev/null
@@ -1,12 +0,0 @@
-projectionHandler = $projectionHandler;
- }
-
- public function __invoke(Message $message): void
- {
- $this->projectionHandler->handle($message);
- }
-}
diff --git a/src/Projection/Projector/MetadataProjectorResolver.php b/src/Projection/Projector/MetadataProjectorResolver.php
index a5517158..05028124 100644
--- a/src/Projection/Projector/MetadataProjectorResolver.php
+++ b/src/Projection/Projector/MetadataProjectorResolver.php
@@ -8,7 +8,6 @@
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Metadata\Projection\AttributeProjectionMetadataFactory;
use Patchlevel\EventSourcing\Metadata\Projection\ProjectionMetadataFactory;
-use Patchlevel\EventSourcing\Projection\Projection;
use function array_key_exists;
@@ -19,7 +18,7 @@ public function __construct(
) {
}
- public function resolveCreateMethod(Projection $projector): ?Closure
+ public function resolveCreateMethod(Projector $projector): ?Closure
{
$metadata = $this->metadataFactory->metadata($projector::class);
$method = $metadata->createMethod;
@@ -31,7 +30,7 @@ public function resolveCreateMethod(Projection $projector): ?Closure
return $projector->$method(...);
}
- public function resolveDropMethod(Projection $projector): ?Closure
+ public function resolveDropMethod(Projector $projector): ?Closure
{
$metadata = $this->metadataFactory->metadata($projector::class);
$method = $metadata->dropMethod;
@@ -43,7 +42,7 @@ public function resolveDropMethod(Projection $projector): ?Closure
return $projector->$method(...);
}
- public function resolveHandleMethod(Projection $projector, Message $message): ?Closure
+ public function resolveHandleMethod(Projector $projector, Message $message): ?Closure
{
$event = $message->event();
$metadata = $this->metadataFactory->metadata($projector::class);
diff --git a/src/Projection/Projector/Projector.php b/src/Projection/Projector/Projector.php
index cdf620ab..b07e7320 100644
--- a/src/Projection/Projector/Projector.php
+++ b/src/Projection/Projector/Projector.php
@@ -4,8 +4,6 @@
namespace Patchlevel\EventSourcing\Projection\Projector;
-use Patchlevel\EventSourcing\Projection\Projection;
-
-interface Projector extends Projection
+interface Projector
{
}
diff --git a/src/Projection/Projector/ProjectorResolver.php b/src/Projection/Projector/ProjectorResolver.php
index dbdd70be..a4f2de13 100644
--- a/src/Projection/Projector/ProjectorResolver.php
+++ b/src/Projection/Projector/ProjectorResolver.php
@@ -6,13 +6,12 @@
use Closure;
use Patchlevel\EventSourcing\EventBus\Message;
-use Patchlevel\EventSourcing\Projection\Projection;
interface ProjectorResolver
{
- public function resolveCreateMethod(Projection $projector): ?Closure;
+ public function resolveCreateMethod(Projector $projector): ?Closure;
- public function resolveDropMethod(Projection $projector): ?Closure;
+ public function resolveDropMethod(Projector $projector): ?Closure;
- public function resolveHandleMethod(Projection $projector, Message $message): ?Closure;
+ public function resolveHandleMethod(Projector $projector, Message $message): ?Closure;
}
diff --git a/src/Repository/InvalidAggregateClass.php b/src/Repository/InvalidAggregateClass.php
deleted file mode 100644
index e10c5a80..00000000
--- a/src/Repository/InvalidAggregateClass.php
+++ /dev/null
@@ -1,29 +0,0 @@
-connection();
- $queries = $this->dryRunCreate($store);
-
- foreach ($queries as $sql) {
- $connection->executeStatement($sql);
- }
- }
-
- /**
- * @return list
- */
- public function dryRunCreate(Store $store): array
- {
- if (!$store instanceof DoctrineStore) {
- throw new StoreNotSupported($store, DoctrineStore::class);
- }
-
- return $store->schema()->toSql($store->connection()->getDatabasePlatform());
- }
-
- public function update(Store $store): void
- {
- if (!$store instanceof DoctrineStore) {
- throw new StoreNotSupported($store, DoctrineStore::class);
- }
-
- $connection = $store->connection();
- $queries = $this->dryRunUpdate($store);
-
- foreach ($queries as $sql) {
- $connection->executeStatement($sql);
- }
- }
-
- /**
- * @return list
- */
- public function dryRunUpdate(Store $store): array
- {
- if (!$store instanceof DoctrineStore) {
- throw new StoreNotSupported($store, DoctrineStore::class);
- }
-
- $connection = $store->connection();
- $schemaManager = $connection->createSchemaManager();
-
- $fromSchema = $schemaManager->createSchema();
- $toSchema = $store->schema();
-
- $comparator = $schemaManager->createComparator();
- $diff = $comparator->compareSchemas($fromSchema, $toSchema);
-
- return $diff->toSql($connection->getDatabasePlatform());
- }
-
- public function drop(Store $store): void
- {
- if (!$store instanceof DoctrineStore) {
- throw new StoreNotSupported($store, DoctrineStore::class);
- }
-
- $connection = $store->connection();
- $queries = $this->dryRunDrop($store);
-
- foreach ($queries as $sql) {
- $connection->executeStatement($sql);
- }
- }
-
- /**
- * @return list
- */
- public function dryRunDrop(Store $store): array
- {
- if (!$store instanceof DoctrineStore) {
- throw new StoreNotSupported($store, DoctrineStore::class);
- }
-
- $connection = $store->connection();
- $currentSchema = $connection->createSchemaManager()->createSchema();
- $schema = $store->schema();
-
- $queries = [];
-
- foreach ($schema->getTables() as $table) {
- if (!$currentSchema->hasTable($table->getName())) {
- continue;
- }
-
- $queries[] = sprintf('DROP TABLE %s;', $table->getName());
- }
-
- return $queries;
- }
-}
diff --git a/src/Schema/DryRunSchemaManager.php b/src/Schema/DryRunSchemaManager.php
deleted file mode 100644
index bd60eb93..00000000
--- a/src/Schema/DryRunSchemaManager.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
- */
- public function dryRunCreate(Store $store): array;
-
- /**
- * @return list
- */
- public function dryRunUpdate(Store $store): array;
-
- /**
- * @return list
- */
- public function dryRunDrop(Store $store): array;
-}
diff --git a/src/Schema/MigrationSchemaProvider.php b/src/Schema/MigrationSchemaProvider.php
deleted file mode 100644
index 5fc3cfb8..00000000
--- a/src/Schema/MigrationSchemaProvider.php
+++ /dev/null
@@ -1,25 +0,0 @@
-doctrineStore->schema();
- }
-}
diff --git a/src/Schema/SchemaManager.php b/src/Schema/SchemaManager.php
deleted file mode 100644
index 486c5cfe..00000000
--- a/src/Schema/SchemaManager.php
+++ /dev/null
@@ -1,19 +0,0 @@
-
- */
- public function stream(int $fromIndex = 0): Generator;
-
- public function count(int $fromIndex = 0): int;
-}
diff --git a/src/Store/StreamableStore.php b/src/Store/StreamableStore.php
index fa096cb5..129c4ba5 100644
--- a/src/Store/StreamableStore.php
+++ b/src/Store/StreamableStore.php
@@ -7,7 +7,7 @@
use Generator;
use Patchlevel\EventSourcing\EventBus\Message;
-interface StreamableStore extends PipelineStore
+interface StreamableStore
{
/**
* @return Generator
diff --git a/tests/Benchmark/WriteEventsBench.php b/tests/Benchmark/WriteEventsBench.php
index 536e648b..2309f546 100644
--- a/tests/Benchmark/WriteEventsBench.php
+++ b/tests/Benchmark/WriteEventsBench.php
@@ -9,8 +9,8 @@
use Patchlevel\EventSourcing\EventBus\DefaultEventBus;
use Patchlevel\EventSourcing\EventBus\EventBus;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionListener;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\SyncProjectorListener;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Repository\Repository;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
@@ -48,12 +48,12 @@ public function setUp(): void
]);
$profileProjection = new ProfileProjector($connection);
- $projectionRepository = new MetadataAwareProjectionHandler(
+ $projectionRepository = new InMemoryProjectorRepository(
[$profileProjection]
);
$this->bus = new DefaultEventBus();
- $this->bus->addListener(new ProjectionListener($projectionRepository));
+ $this->bus->addListener(new SyncProjectorListener($projectionRepository));
$this->bus->addListener(new SendEmailProcessor());
$this->store = new SingleTableStore(
diff --git a/tests/Integration/BankAccountSplitStream/IntegrationTest.php b/tests/Integration/BankAccountSplitStream/IntegrationTest.php
index b524d6cf..79b65310 100644
--- a/tests/Integration/BankAccountSplitStream/IntegrationTest.php
+++ b/tests/Integration/BankAccountSplitStream/IntegrationTest.php
@@ -13,8 +13,8 @@
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AggregateRootRegistry;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
use Patchlevel\EventSourcing\Metadata\Event\AttributeEventMetadataFactory;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionListener;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\SyncProjectorListener;
use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
@@ -50,10 +50,10 @@ public function tearDown(): void
public function testSingleTableSuccessful(): void
{
$bankAccountProjection = new BankAccountProjection($this->connection);
- $projectionRepository = new MetadataAwareProjectionHandler([$bankAccountProjection]);
+ $projectionRepository = new InMemoryProjectorRepository([$bankAccountProjection]);
$eventStream = new DefaultEventBus();
- $eventStream->addListener(new ProjectionListener($projectionRepository));
+ $eventStream->addListener(new SyncProjectorListener($projectionRepository));
$store = new SingleTableStore(
$this->connection,
@@ -156,10 +156,10 @@ public function testSingleTableSuccessful(): void
public function testMultiTableSuccessful(): void
{
$bankAccountProjection = new BankAccountProjection($this->connection);
- $projectionRepository = new MetadataAwareProjectionHandler([$bankAccountProjection]);
+ $projectionRepository = new InMemoryProjectorRepository([$bankAccountProjection]);
$eventStream = new DefaultEventBus();
- $eventStream->addListener(new ProjectionListener($projectionRepository));
+ $eventStream->addListener(new SyncProjectorListener($projectionRepository));
$store = new MultiTableStore(
$this->connection,
diff --git a/tests/Integration/Outbox/OutboxTest.php b/tests/Integration/Outbox/OutboxTest.php
index 91665ad0..fa6ca8b5 100644
--- a/tests/Integration/Outbox/OutboxTest.php
+++ b/tests/Integration/Outbox/OutboxTest.php
@@ -9,8 +9,8 @@
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
use Patchlevel\EventSourcing\Outbox\OutboxEventBus;
use Patchlevel\EventSourcing\Outbox\StoreOutboxConsumer;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionListener;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
+use Patchlevel\EventSourcing\Projection\Projector\SyncProjectorListener;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaDirector;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
@@ -43,7 +43,7 @@ public function tearDown(): void
public function testSuccessful(): void
{
$profileProjection = new ProfileProjection($this->connection);
- $projectionRepository = new MetadataAwareProjectionHandler(
+ $projectionRepository = new InMemoryProjectorRepository(
[$profileProjection]
);
@@ -55,7 +55,7 @@ public function testSuccessful(): void
);
$realEventBus = new DefaultEventBus();
- $realEventBus->addListener(new ProjectionListener($projectionRepository));
+ $realEventBus->addListener(new SyncProjectorListener($projectionRepository));
$realEventBus->addListener(new SendEmailProcessor());
$outboxEventBus = new OutboxEventBus($store);
diff --git a/tests/Unit/Console/Command/ProjectionCreateCommandTest.php b/tests/Unit/Console/Command/ProjectionCreateCommandTest.php
index 565e4601..ae1b6e06 100644
--- a/tests/Unit/Console/Command/ProjectionCreateCommandTest.php
+++ b/tests/Unit/Console/Command/ProjectionCreateCommandTest.php
@@ -5,8 +5,7 @@
namespace Patchlevel\EventSourcing\Tests\Unit\Console\Command;
use Patchlevel\EventSourcing\Console\Command\ProjectionCreateCommand;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionHandler;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Dummy2Projection;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\DummyProjection;
use PHPUnit\Framework\TestCase;
@@ -24,12 +23,11 @@ final class ProjectionCreateCommandTest extends TestCase
public function testSuccessful(): void
{
- $repository = $this->prophesize(ProjectionHandler::class);
- $repository->create()->shouldBeCalled();
+ $projectionA = new DummyProjection();
+ $projectionB = new Dummy2Projection();
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
- $command = new ProjectionCreateCommand(
- $repository->reveal()
- );
+ $command = new ProjectionCreateCommand($repository);
$input = new ArrayInput([]);
$output = new BufferedOutput();
@@ -38,6 +36,9 @@ public function testSuccessful(): void
self::assertSame(0, $exitCode);
+ self::assertTrue($projectionA->createCalled);
+ self::assertTrue($projectionB->createCalled);
+
$content = $output->fetch();
self::assertStringContainsString('[OK] projection created', $content);
@@ -47,11 +48,9 @@ public function testSpecificProjection(): void
{
$projectionA = new DummyProjection();
$projectionB = new Dummy2Projection();
- $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]);
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
- $command = new ProjectionCreateCommand(
- $handler
- );
+ $command = new ProjectionCreateCommand($repository);
$input = new ArrayInput(['--projection' => DummyProjection::class]);
$output = new BufferedOutput();
diff --git a/tests/Unit/Console/Command/ProjectionDropCommandTest.php b/tests/Unit/Console/Command/ProjectionDropCommandTest.php
index ffd62f4f..e5bd10c5 100644
--- a/tests/Unit/Console/Command/ProjectionDropCommandTest.php
+++ b/tests/Unit/Console/Command/ProjectionDropCommandTest.php
@@ -5,8 +5,7 @@
namespace Patchlevel\EventSourcing\Tests\Unit\Console\Command;
use Patchlevel\EventSourcing\Console\Command\ProjectionDropCommand;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionHandler;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Dummy2Projection;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\DummyProjection;
use PHPUnit\Framework\TestCase;
@@ -24,12 +23,11 @@ final class ProjectionDropCommandTest extends TestCase
public function testSuccessful(): void
{
- $repository = $this->prophesize(ProjectionHandler::class);
- $repository->drop()->shouldBeCalled();
+ $projectionA = new DummyProjection();
+ $projectionB = new Dummy2Projection();
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
- $command = new ProjectionDropCommand(
- $repository->reveal()
- );
+ $command = new ProjectionDropCommand($repository);
$input = new ArrayInput([]);
$output = new BufferedOutput();
@@ -38,6 +36,9 @@ public function testSuccessful(): void
self::assertSame(0, $exitCode);
+ self::assertTrue($projectionA->dropCalled);
+ self::assertTrue($projectionB->dropCalled);
+
$content = $output->fetch();
self::assertStringContainsString('[OK] projection deleted', $content);
@@ -47,11 +48,9 @@ public function testSpecificProjection(): void
{
$projectionA = new DummyProjection();
$projectionB = new Dummy2Projection();
- $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]);
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
- $command = new ProjectionDropCommand(
- $handler
- );
+ $command = new ProjectionDropCommand($repository);
$input = new ArrayInput(['--projection' => DummyProjection::class]);
$output = new BufferedOutput();
diff --git a/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php b/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php
index 824cc68f..e8439c55 100644
--- a/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php
+++ b/tests/Unit/Console/Command/ProjectionRebuildCommandTest.php
@@ -8,10 +8,8 @@
use Generator;
use Patchlevel\EventSourcing\Console\Command\ProjectionRebuildCommand;
use Patchlevel\EventSourcing\EventBus\Message;
-use Patchlevel\EventSourcing\Projection\MetadataAwareProjectionHandler;
-use Patchlevel\EventSourcing\Projection\ProjectionHandler;
-use Patchlevel\EventSourcing\Store\PipelineStore;
-use Patchlevel\EventSourcing\Store\Store;
+use Patchlevel\EventSourcing\Projection\Projector\InMemoryProjectorRepository;
+use Patchlevel\EventSourcing\Store\StreamableStore;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Dummy2Projection;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\DummyProjection;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email;
@@ -63,16 +61,16 @@ public function setUp(): void
public function testSuccessful(): void
{
- $store = $this->prophesize(PipelineStore::class);
+ $projectionA = new DummyProjection();
+ $repository = new InMemoryProjectorRepository([$projectionA]);
+
+ $store = $this->prophesize(StreamableStore::class);
$store->count(Argument::is(0))->willReturn(5);
$store->stream(Argument::is(0))->willReturn(($this->messages)());
- $repository = $this->prophesize(ProjectionHandler::class);
- $repository->handle(Argument::type(Message::class))->shouldBeCalledTimes(5);
-
$command = new ProjectionRebuildCommand(
$store->reveal(),
- $repository->reveal()
+ $repository
);
$input = new ArrayInput([]);
@@ -84,23 +82,26 @@ public function testSuccessful(): void
$content = $output->fetch();
+ self::assertInstanceOf(Message::class, $projectionA->handledMessage);
+ self::assertInstanceOf(ProfileCreated::class, $projectionA->handledMessage->event());
+
self::assertStringContainsString('[WARNING] rebuild projections', $content);
self::assertStringContainsString('[OK] finish', $content);
}
public function testSpecificProjection(): void
{
- $store = $this->prophesize(PipelineStore::class);
+ $store = $this->prophesize(StreamableStore::class);
$store->count(Argument::is(0))->willReturn(5);
$store->stream(Argument::is(0))->willReturn(($this->messages)());
$projectionA = new DummyProjection();
$projectionB = new Dummy2Projection();
- $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]);
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
$command = new ProjectionRebuildCommand(
$store->reveal(),
- $handler
+ $repository
);
$input = new ArrayInput(['--projection' => $projectionA::class]);
@@ -120,18 +121,17 @@ public function testSpecificProjection(): void
public function testRecreate(): void
{
- $store = $this->prophesize(PipelineStore::class);
+ $projectionA = new DummyProjection();
+
+ $store = $this->prophesize(StreamableStore::class);
$store->count(Argument::is(0))->willReturn(5);
$store->stream(Argument::is(0))->willReturn(($this->messages)());
- $repository = $this->prophesize(ProjectionHandler::class);
- $repository->drop(null)->shouldBeCalled();
- $repository->create(null)->shouldBeCalled();
- $repository->handle(Argument::type(Message::class))->shouldBeCalledTimes(5);
+ $repository = new InMemoryProjectorRepository([$projectionA]);
$command = new ProjectionRebuildCommand(
$store->reveal(),
- $repository->reveal()
+ $repository
);
$input = new ArrayInput(['--recreate' => true]);
@@ -143,6 +143,9 @@ public function testRecreate(): void
$content = $output->fetch();
+ self::assertTrue($projectionA->createCalled);
+ self::assertTrue($projectionA->dropCalled);
+
self::assertStringContainsString('[OK] projection schema deleted', $content);
self::assertStringContainsString('[OK] projection schema created', $content);
self::assertStringContainsString('[WARNING] rebuild projections', $content);
@@ -151,17 +154,17 @@ public function testRecreate(): void
public function testRecreateWithSpecificProjection(): void
{
- $store = $this->prophesize(PipelineStore::class);
+ $store = $this->prophesize(StreamableStore::class);
$store->count(Argument::is(0))->willReturn(5);
$store->stream(Argument::is(0))->willReturn(($this->messages)());
$projectionA = new DummyProjection();
$projectionB = new Dummy2Projection();
- $handler = new MetadataAwareProjectionHandler([$projectionA, $projectionB]);
+ $repository = new InMemoryProjectorRepository([$projectionA, $projectionB]);
$command = new ProjectionRebuildCommand(
$store->reveal(),
- $handler
+ $repository
);
$input = new ArrayInput(['--recreate' => true, '--projection' => DummyProjection::class]);
@@ -184,26 +187,4 @@ public function testRecreateWithSpecificProjection(): void
self::assertStringContainsString('[WARNING] rebuild projections', $content);
self::assertStringContainsString('[OK] finish', $content);
}
-
- public function testStoreNotSupported(): void
- {
- $store = $this->prophesize(Store::class);
- $repository = $this->prophesize(ProjectionHandler::class);
-
- $command = new ProjectionRebuildCommand(
- $store->reveal(),
- $repository->reveal()
- );
-
- $input = new ArrayInput([]);
- $output = new BufferedOutput();
-
- $exitCode = $command->run($input, $output);
-
- self::assertSame(1, $exitCode);
-
- $content = $output->fetch();
-
- self::assertStringContainsString('[ERROR] store is not supported', $content);
- }
}
diff --git a/tests/Unit/Console/Command/SchemaCreateCommandTest.php b/tests/Unit/Console/Command/SchemaCreateCommandTest.php
index f999a634..6f92def0 100644
--- a/tests/Unit/Console/Command/SchemaCreateCommandTest.php
+++ b/tests/Unit/Console/Command/SchemaCreateCommandTest.php
@@ -7,7 +7,6 @@
use Patchlevel\EventSourcing\Console\Command\SchemaCreateCommand;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Store\Store;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Console\Input\ArrayInput;
@@ -20,13 +19,10 @@ final class SchemaCreateCommandTest extends TestCase
public function testSuccessful(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
- $schemaManager->create($store)->shouldBeCalled();
+ $schemaManager->create()->shouldBeCalled();
$command = new SchemaCreateCommand(
- $store,
$schemaManager->reveal()
);
@@ -44,17 +40,14 @@ public function testSuccessful(): void
public function testDryRun(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(DryRunSchemaDirector::class);
- $schemaManager->dryRunCreate($store)->willReturn([
+ $schemaManager->dryRunCreate()->willReturn([
'create table 1;',
'create table 2;',
'create table 3;',
]);
$command = new SchemaCreateCommand(
- $store,
$schemaManager->reveal()
);
@@ -75,12 +68,9 @@ public function testDryRun(): void
public function testDryRunNotSupported(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
$command = new SchemaCreateCommand(
- $store,
$schemaManager->reveal()
);
diff --git a/tests/Unit/Console/Command/SchemaDropCommandTest.php b/tests/Unit/Console/Command/SchemaDropCommandTest.php
index 7164a4c5..e36b0682 100644
--- a/tests/Unit/Console/Command/SchemaDropCommandTest.php
+++ b/tests/Unit/Console/Command/SchemaDropCommandTest.php
@@ -7,7 +7,6 @@
use Patchlevel\EventSourcing\Console\Command\SchemaDropCommand;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Store\Store;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Console\Input\ArrayInput;
@@ -20,13 +19,10 @@ final class SchemaDropCommandTest extends TestCase
public function testSuccessful(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
- $schemaManager->drop($store)->shouldBeCalled();
+ $schemaManager->drop()->shouldBeCalled();
$command = new SchemaDropCommand(
- $store,
$schemaManager->reveal()
);
@@ -44,13 +40,10 @@ public function testSuccessful(): void
public function testMissingForce(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
- $schemaManager->drop($store)->shouldNotBeCalled();
+ $schemaManager->drop()->shouldNotBeCalled();
$command = new SchemaDropCommand(
- $store,
$schemaManager->reveal()
);
@@ -71,17 +64,14 @@ public function testMissingForce(): void
public function testDryRun(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(DryRunSchemaDirector::class);
- $schemaManager->dryRunDrop($store)->willReturn([
+ $schemaManager->dryRunDrop()->willReturn([
'drop table 1;',
'drop table 2;',
'drop table 3;',
]);
$command = new SchemaDropCommand(
- $store,
$schemaManager->reveal()
);
@@ -102,12 +92,9 @@ public function testDryRun(): void
public function testDryRunNotSupported(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
$command = new SchemaDropCommand(
- $store,
$schemaManager->reveal()
);
diff --git a/tests/Unit/Console/Command/SchemaUpdateCommandTest.php b/tests/Unit/Console/Command/SchemaUpdateCommandTest.php
index fb79d558..f64a891b 100644
--- a/tests/Unit/Console/Command/SchemaUpdateCommandTest.php
+++ b/tests/Unit/Console/Command/SchemaUpdateCommandTest.php
@@ -7,7 +7,6 @@
use Patchlevel\EventSourcing\Console\Command\SchemaUpdateCommand;
use Patchlevel\EventSourcing\Schema\DryRunSchemaDirector;
use Patchlevel\EventSourcing\Schema\SchemaDirector;
-use Patchlevel\EventSourcing\Store\Store;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Console\Input\ArrayInput;
@@ -20,13 +19,10 @@ final class SchemaUpdateCommandTest extends TestCase
public function testSuccessful(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
- $schemaManager->update($store)->shouldBeCalled();
+ $schemaManager->update()->shouldBeCalled();
$command = new SchemaUpdateCommand(
- $store,
$schemaManager->reveal()
);
@@ -44,13 +40,10 @@ public function testSuccessful(): void
public function testMissingForce(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
- $schemaManager->update($store)->shouldNotBeCalled();
+ $schemaManager->update()->shouldNotBeCalled();
$command = new SchemaUpdateCommand(
- $store,
$schemaManager->reveal()
);
@@ -71,17 +64,14 @@ public function testMissingForce(): void
public function testDryRun(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(DryRunSchemaDirector::class);
- $schemaManager->dryRunUpdate($store)->willReturn([
+ $schemaManager->dryRunUpdate()->willReturn([
'update table 1;',
'update table 2;',
'update table 3;',
]);
$command = new SchemaUpdateCommand(
- $store,
$schemaManager->reveal()
);
@@ -101,12 +91,9 @@ public function testDryRun(): void
public function testDryRunNotSupported(): void
{
- $store = $this->prophesize(Store::class)->reveal();
-
$schemaManager = $this->prophesize(SchemaDirector::class);
$command = new SchemaUpdateCommand(
- $store,
$schemaManager->reveal()
);
diff --git a/tests/Unit/Fixture/Dummy2Projection.php b/tests/Unit/Fixture/Dummy2Projection.php
index 45bf5ab0..452970c6 100644
--- a/tests/Unit/Fixture/Dummy2Projection.php
+++ b/tests/Unit/Fixture/Dummy2Projection.php
@@ -8,9 +8,9 @@
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Handle;
use Patchlevel\EventSourcing\EventBus\Message as EventMessage;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
-final class Dummy2Projection implements Projection
+final class Dummy2Projection implements Projector
{
public ?EventMessage $handledMessage = null;
public bool $createCalled = false;
diff --git a/tests/Unit/Fixture/DummyProjection.php b/tests/Unit/Fixture/DummyProjection.php
index 95fe50e5..43365757 100644
--- a/tests/Unit/Fixture/DummyProjection.php
+++ b/tests/Unit/Fixture/DummyProjection.php
@@ -8,9 +8,9 @@
use Patchlevel\EventSourcing\Attribute\Drop;
use Patchlevel\EventSourcing\Attribute\Handle;
use Patchlevel\EventSourcing\EventBus\Message as EventMessage;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
-final class DummyProjection implements Projection
+final class DummyProjection implements Projector
{
public ?EventMessage $handledMessage = null;
public bool $createCalled = false;
diff --git a/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php b/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php
index c5729f61..e7fc5883 100644
--- a/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php
+++ b/tests/Unit/Metadata/Projection/AttributeProjectionMetadataFactoryTest.php
@@ -10,7 +10,7 @@
use Patchlevel\EventSourcing\Metadata\Projection\AttributeProjectionMetadataFactory;
use Patchlevel\EventSourcing\Metadata\Projection\DuplicateCreateMethod;
use Patchlevel\EventSourcing\Metadata\Projection\DuplicateDropMethod;
-use Patchlevel\EventSourcing\Projection\Projection;
+use Patchlevel\EventSourcing\Projection\Projector\Projector;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileVisited;
use PHPUnit\Framework\TestCase;
@@ -19,7 +19,7 @@ final class AttributeProjectionMetadataFactoryTest extends TestCase
{
public function testEmptyProjection(): void
{
- $projection = new class implements Projection {
+ $projection = new class implements Projector {
};
$metadataFactory = new AttributeProjectionMetadataFactory();
@@ -32,7 +32,7 @@ public function testEmptyProjection(): void
public function testStandardProjection(): void
{
- $projection = new class implements Projection {
+ $projection = new class implements Projector {
#[Handle(ProfileVisited::class)]
public function handle(): void
{
@@ -63,7 +63,7 @@ public function drop(): void
public function testMultipleHandlerOnOneMethod(): void
{
- $projection = new class implements Projection {
+ $projection = new class implements Projector {
#[Handle(ProfileVisited::class)]
#[Handle(ProfileCreated::class)]
public function handle(): void
@@ -87,7 +87,7 @@ public function testDuplicateCreateAttributeException(): void
{
$this->expectException(DuplicateCreateMethod::class);
- $projection = new class implements Projection {
+ $projection = new class implements Projector {
#[Create]
public function create1(): void
{
@@ -107,7 +107,7 @@ public function testDuplicateDropAttributeException(): void
{
$this->expectException(DuplicateDropMethod::class);
- $projection = new class implements Projection {
+ $projection = new class implements Projector {
#[Drop]
public function drop1(): void
{
diff --git a/tests/Unit/Pipeline/Source/StoreSourceTest.php b/tests/Unit/Pipeline/Source/StoreSourceTest.php
index d564eaeb..502b564b 100644
--- a/tests/Unit/Pipeline/Source/StoreSourceTest.php
+++ b/tests/Unit/Pipeline/Source/StoreSourceTest.php
@@ -7,7 +7,7 @@
use Generator;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Pipeline\Source\StoreSource;
-use Patchlevel\EventSourcing\Store\PipelineStore;
+use Patchlevel\EventSourcing\Store\StreamableStore;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId;
@@ -29,7 +29,7 @@ public function testLoad(): void
yield $message;
};
- $pipelineStore = $this->prophesize(PipelineStore::class);
+ $pipelineStore = $this->prophesize(StreamableStore::class);
$pipelineStore->stream(0)->willReturn($generatorFactory());
$source = new StoreSource($pipelineStore->reveal());
@@ -53,7 +53,7 @@ public function testLoadWithFromIndex(): void
yield $message;
};
- $pipelineStore = $this->prophesize(PipelineStore::class);
+ $pipelineStore = $this->prophesize(StreamableStore::class);
$pipelineStore->stream(1)->willReturn($generatorFactory());
$source = new StoreSource($pipelineStore->reveal(), 1);
@@ -69,7 +69,7 @@ public function testLoadWithFromIndex(): void
public function testCount(): void
{
- $pipelineStore = $this->prophesize(PipelineStore::class);
+ $pipelineStore = $this->prophesize(StreamableStore::class);
$pipelineStore->count(0)->willReturn(1);
$source = new StoreSource($pipelineStore->reveal());
@@ -79,7 +79,7 @@ public function testCount(): void
public function testCountWithFromIndex(): void
{
- $pipelineStore = $this->prophesize(PipelineStore::class);
+ $pipelineStore = $this->prophesize(StreamableStore::class);
$pipelineStore->count(1)->willReturn(0);
$source = new StoreSource($pipelineStore->reveal(), 1);
diff --git a/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php b/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php
deleted file mode 100644
index a62fae00..00000000
--- a/tests/Unit/Pipeline/Target/ProjectionHandlerTargetTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-prophesize(ProjectionHandler::class);
- $projectionHandler->handle($message)->shouldBeCalledOnce();
-
- $projectionHandlerTarget = new ProjectionHandlerTarget($projectionHandler->reveal());
-
- $projectionHandlerTarget->save($message);
- }
-}
diff --git a/tests/Unit/Pipeline/Target/ProjectionTargetTest.php b/tests/Unit/Pipeline/Target/ProjectionTargetTest.php
deleted file mode 100644
index 1c2d5969..00000000
--- a/tests/Unit/Pipeline/Target/ProjectionTargetTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-save($message);
-
- self::assertSame($message, $projection::$handledMessage);
- }
-}
diff --git a/tests/Unit/Pipeline/Target/StoreTargetTest.php b/tests/Unit/Pipeline/Target/StoreTargetTest.php
index ee345651..63c97389 100644
--- a/tests/Unit/Pipeline/Target/StoreTargetTest.php
+++ b/tests/Unit/Pipeline/Target/StoreTargetTest.php
@@ -6,7 +6,7 @@
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Pipeline\Target\StoreTarget;
-use Patchlevel\EventSourcing\Store\PipelineStore;
+use Patchlevel\EventSourcing\Store\Store;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId;
@@ -24,7 +24,7 @@ public function testSave(): void
new ProfileCreated(ProfileId::fromString('1'), Email::fromString('foo@test.com'))
);
- $pipelineStore = $this->prophesize(PipelineStore::class);
+ $pipelineStore = $this->prophesize(Store::class);
$pipelineStore->save($message)->shouldBeCalled();
$storeTarget = new StoreTarget($pipelineStore->reveal());
diff --git a/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php b/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php
deleted file mode 100644
index fd15b9e3..00000000
--- a/tests/Unit/Projection/MetadataAwareProjectionHandlerTest.php
+++ /dev/null
@@ -1,130 +0,0 @@
-handle($message);
-
- $this->expectNotToPerformAssertions();
- }
-
- public function testHandle(): void
- {
- $projection = new class implements Projection {
- public static ?Message $handledMessage = null;
-
- #[Handle(ProfileCreated::class)]
- public function handleProfileCreated(Message $message): void
- {
- self::$handledMessage = $message;
- }
- };
-
- $event = new ProfileCreated(
- ProfileId::fromString('1'),
- Email::fromString('profile@test.com')
- );
-
- $message = new Message(
- $event
- );
-
- $projectionRepository = new MetadataAwareProjectionHandler([$projection]);
- $projectionRepository->handle($message);
-
- self::assertSame($message, $projection::$handledMessage);
- }
-
- public function testHandleNotSupportedEvent(): void
- {
- $projection = new class implements Projection {
- public static ?Message $handledMessage = null;
-
- #[Handle(ProfileCreated::class)]
- public function handleProfileCreated(Message $message): void
- {
- self::$handledMessage = $message;
- }
- };
-
- $event = new ProfileVisited(
- ProfileId::fromString('1')
- );
-
- $message = new Message(
- $event
- );
-
- $projectionRepository = new MetadataAwareProjectionHandler([$projection]);
- $projectionRepository->handle($message);
-
- self::assertNull($projection::$handledMessage);
- }
-
- public function testCreate(): void
- {
- $projection = new class implements Projection {
- public static bool $called = false;
-
- #[Create]
- public function method(): void
- {
- self::$called = true;
- }
- };
-
- $projectionRepository = new MetadataAwareProjectionHandler([$projection]);
- $projectionRepository->create();
-
- self::assertTrue($projection::$called);
- }
-
- public function testDrop(): void
- {
- $projection = new class implements Projection {
- public static bool $called = false;
-
- #[Drop]
- public function method(): void
- {
- self::$called = true;
- }
- };
-
- $projectionRepository = new MetadataAwareProjectionHandler([$projection]);
- $projectionRepository->drop();
-
- self::assertTrue($projection::$called);
- }
-}
diff --git a/tests/Unit/Projection/ProjectionListenerTest.php b/tests/Unit/Projection/ProjectionListenerTest.php
deleted file mode 100644
index bef76aa8..00000000
--- a/tests/Unit/Projection/ProjectionListenerTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-prophesize(ProjectionHandler::class);
- $projectionRepository->handle($message)->shouldBeCalledOnce();
-
- $projectionListener = new ProjectionListener($projectionRepository->reveal());
- $projectionListener($message);
- }
-}
diff --git a/tests/Unit/Schema/DoctrineSchemaManagerTest.php b/tests/Unit/Schema/DoctrineSchemaManagerTest.php
deleted file mode 100644
index e743ca51..00000000
--- a/tests/Unit/Schema/DoctrineSchemaManagerTest.php
+++ /dev/null
@@ -1,266 +0,0 @@
-prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $schema = $this->prophesize(Schema::class);
- $platform = $this->prophesize(AbstractPlatform::class);
-
- $connection->getDatabasePlatform()->willReturn($platform->reveal());
- $schema->toSql(Argument::type(AbstractPlatform::class))->willReturn(['this is sql!']);
- $store->schema()->willReturn($schema->reveal());
-
- $connection->executeStatement('this is sql!')->shouldBeCalledOnce();
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $doctrineSchemaManager->create($store->reveal());
- }
-
- public function testCreateNotSupportedStore(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->create($store->reveal());
- }
-
- public function testDryRunCreate(): void
- {
- $store = $this->prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $schema = $this->prophesize(Schema::class);
- $platform = $this->prophesize(AbstractPlatform::class);
-
- $connection->getDatabasePlatform()->willReturn($platform->reveal());
- $schema->toSql(Argument::type(AbstractPlatform::class))->willReturn(['this is sql!']);
- $store->schema()->willReturn($schema->reveal());
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $sqlStatements = $doctrineSchemaManager->dryRunCreate($store->reveal());
-
- self::assertSame(['this is sql!'], $sqlStatements);
- }
-
- public function testDryRunCreateNotSupportedStore(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->dryRunCreate($store->reveal());
- }
-
- public function testUpdate(): void
- {
- $store = $this->prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $fromSchema = $this->prophesize(Schema::class);
- $toSchema = $this->prophesize(Schema::class);
- $schemaManager = $this->prophesize(AbstractSchemaManager::class);
- $platform = $this->prophesize(AbstractPlatform::class);
-
- $table = new Table('foo');
-
- $toSchema->getNamespaces()->willReturn([]);
- $toSchema->getTables()->willReturn([$table]);
- $toSchema->getTable('foo')->willReturn($table);
- $toSchema->getSequences()->willReturn([]);
- $toSchema->getName()->willReturn('toSchema');
-
- $fromSchema->getNamespaces()->willReturn([]);
- $fromSchema->getTables()->willReturn([]);
- $fromSchema->getSequences()->willReturn([]);
- $fromSchema->hasTable('foo')->willReturn(false);
-
- $platform->supportsSchemas()->willReturn(false);
- $platform->supportsForeignKeyConstraints()->willReturn(false);
- $platform->supportsSequences()->willReturn(false);
- $platform->supportsForeignKeyConstraints()->willReturn(false);
-
- $platform->getDropTablesSQL([])->shouldBeCalledOnce()->willReturn([]);
- $platform->getCreateTablesSQL(['foo' => $table])->shouldBeCalledOnce()->willReturn(['CREATE TABLE foo;']);
-
- $schemaManager->createSchema()->willReturn($fromSchema->reveal());
-
- /**
- * @psalm-suppress InternalMethod
- */
- $schemaManager->createComparator()->willReturn(new Comparator());
-
- $connection->createSchemaManager()->willReturn($schemaManager->reveal());
- $connection->getDatabasePlatform()->willReturn($platform->reveal());
- $store->schema()->willReturn($toSchema->reveal());
-
- $connection->executeStatement('CREATE TABLE foo;')->shouldBeCalled();
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $doctrineSchemaManager->update($store->reveal());
- }
-
- public function testUpdateNotSupportedStore(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->update($store->reveal());
- }
-
- public function testDryRunUpdate(): void
- {
- $store = $this->prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $fromSchema = $this->prophesize(Schema::class);
- $toSchema = $this->prophesize(Schema::class);
- $schemaManager = $this->prophesize(AbstractSchemaManager::class);
- $platform = $this->prophesize(AbstractPlatform::class);
-
- $fromSchema->getNamespaces()->willReturn([]);
- $fromSchema->getTables()->willReturn([]);
- $fromSchema->getSequences()->willReturn([]);
- $toSchema->getNamespaces()->willReturn([]);
- $toSchema->getTables()->willReturn([]);
- $toSchema->getSequences()->willReturn([]);
-
- $platform->supportsSchemas()->willReturn(false);
- $platform->supportsForeignKeyConstraints()->willReturn(false);
- $platform->supportsSequences()->willReturn(false);
- $platform->supportsForeignKeyConstraints()->willReturn(false);
-
- $platform->getDropTablesSQL([])->shouldBeCalledOnce()->willReturn([]);
- $platform->getCreateTablesSQL([])->shouldBeCalledOnce()->willReturn([]);
-
- $schemaManager->createSchema()->willReturn($fromSchema->reveal());
-
- /**
- * @psalm-suppress InternalMethod
- */
- $schemaManager->createComparator()->willReturn(new Comparator());
-
- $connection->createSchemaManager()->willReturn($schemaManager->reveal());
- $connection->getDatabasePlatform()->willReturn($platform->reveal());
- $store->schema()->willReturn($toSchema->reveal());
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $sqlStatements = $doctrineSchemaManager->dryRunUpdate($store->reveal());
-
- self::assertSame([], $sqlStatements);
- }
-
- public function testDryRunUpdateNotSupportedStore(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->dryRunUpdate($store->reveal());
- }
-
- public function testDrop(): void
- {
- $store = $this->prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $currentSchema = $this->prophesize(Schema::class);
- $toSchema = $this->prophesize(Schema::class);
- $schemaManager = $this->prophesize(AbstractSchemaManager::class);
-
- $toSchema->getTables()->willReturn([
- new Table('foo'),
- new Table('bar'),
- ]);
-
- $currentSchema->hasTable('foo')->willReturn(true);
- $currentSchema->hasTable('bar')->willReturn(false);
-
- $schemaManager->createSchema()->willReturn($currentSchema->reveal());
- $connection->createSchemaManager()->willReturn($schemaManager->reveal());
- $store->schema()->willReturn($toSchema->reveal());
-
- $connection->executeStatement('DROP TABLE foo;')->shouldBeCalled();
- $connection->executeStatement('DROP TABLE bar;')->shouldNotBeCalled();
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $doctrineSchemaManager->drop($store->reveal());
- }
-
- public function testDropNotSupported(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->drop($store->reveal());
- }
-
- public function testdDryRunDrop(): void
- {
- $store = $this->prophesize(DoctrineStore::class);
- $connection = $this->prophesize(Connection::class);
- $currentSchema = $this->prophesize(Schema::class);
- $toSchema = $this->prophesize(Schema::class);
- $schemaManager = $this->prophesize(AbstractSchemaManager::class);
-
- $toSchema->getTables()->willReturn([
- new Table('foo'),
- new Table('bar'),
- ]);
-
- $currentSchema->hasTable('foo')->willReturn(true);
- $currentSchema->hasTable('bar')->willReturn(false);
-
- $schemaManager->createSchema()->willReturn($currentSchema->reveal());
- $connection->createSchemaManager()->willReturn($schemaManager->reveal());
- $store->schema()->willReturn($toSchema->reveal());
-
- $store->connection()->willReturn($connection->reveal());
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
- $queries = $doctrineSchemaManager->dryRunDrop($store->reveal());
- self::assertSame(['DROP TABLE foo;'], $queries);
- }
-
- public function testDryRunDropNotSupported(): void
- {
- $store = $this->prophesize(Store::class);
-
- $doctrineSchemaManager = new DoctrineSchemaManager();
-
- $this->expectException(StoreNotSupported::class);
- $doctrineSchemaManager->dryRunDrop($store->reveal());
- }
-}
diff --git a/tests/Unit/Schema/MigrationSchemaProviderTest.php b/tests/Unit/Schema/MigrationSchemaProviderTest.php
deleted file mode 100644
index 0a8043bc..00000000
--- a/tests/Unit/Schema/MigrationSchemaProviderTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-prophesize(DoctrineStore::class);
- $store->schema()->willReturn($expectedSchema);
-
- $doctrineSchemaManager = new MigrationSchemaProvider($store->reveal());
- $schema = $doctrineSchemaManager->createSchema();
-
- $this->assertEquals($expectedSchema, $schema);
- }
-}