/** * @param callable|ApplicationConfig $config * * @return ConsoleApplication */ protected function createApplication($config) { $commandBus = CommandBus::create(); $eventBus = DomainEventPublisher::eventBus(); $migrationsService = new MigrationsService(new Migrator($this->getClassMetadataFactory(), new InMemoryMigrationStore(), new InMemoryEventStore(), $this->migrationsDirectory)); $commandBus->addHandler(MigrationsGenerateCommand::class, $migrationsService); $commandBus->addHandler(MigrationsMigrateCommand::class, $migrationsService); $commandBus->addHandler(MigrationsStatusCommand::class, $migrationsService); return new ConsoleApplication($config, $commandBus, $eventBus); }
/** * Test handlerMiddleware method. */ public function testHandlerMiddleware() { $this->given($commandBus = CommandBus::create())->when($middleware = $commandBus->handlerMiddleware())->then()->object($middleware)->isInstanceOf(CommandHandlerMiddleware::class); }
/** * @param callable|ApplicationConfig $config * * @return ConsoleApplication */ protected function createApplication($config) { $commandBus = CommandBus::create(); $eventBus = EventBus::create(); $postService = new PostService($eventBus); $commandBus->addHandler(CreateBlogCommand::class, new BlogService($eventBus)); $commandBus->addHandler(CreatePostCommand::class, $postService); $commandBus->addHandler(ChangePostTitleCommand::class, $postService); return new ConsoleApplication($config, $commandBus, $eventBus); }