Exemplo n.º 1
0
 public function test_that_command_is_executed_by_pipeline()
 {
     $handler = new RegisterUserHandler();
     $this->commandMap->registerHandlers([RegisterUserCommand::class => $handler]);
     $command = new RegisterUserCommand();
     $command->setFirstName('James')->setMiddleName('D')->setLastName('Smith')->setEmail('*****@*****.**')->setPassword('secret');
     $this->pipeline->execute($command);
     $this->assertTrue($this->commandMap->hasHandler(RegisterUserCommand::class) && $this->logHandler->hasInfoThatContains(sprintf('Command received {%s}', ClassName::canonical(RegisterUserCommand::class))) && $this->logHandler->hasInfoThatContains(sprintf('Command handled {%s}', ClassName::canonical(RegisterUserCommand::class))) && $handler->isHandled());
 }
Exemplo n.º 2
0
 public function test_that_create_returns_message_from_command()
 {
     $command = new RegisterUserCommand();
     $command->setFirstName('James')->setMiddleName('D')->setLastName('Smith')->setEmail('*****@*****.**')->setPassword('secret');
     $message = CommandMessage::create($command);
     /** @var RegisterUserCommand $payload */
     $payload = $message->payload();
     $this->assertSame('*****@*****.**', $payload->getEmail());
 }
 public function test_that_it_matches_the_correct_handler_instance()
 {
     $command = new RegisterUserCommand();
     $command->setFirstName('James')->setMiddleName('D')->setLastName('Smith')->setEmail('*****@*****.**')->setPassword('secret');
     /** @var CommandBus $commandBus */
     $commandBus = $this->container->get('command.bus');
     $commandBus->execute($command);
     /** @var RegisterUserHandler $handler */
     $handler = $this->container->get('command.handler.register_user');
     $this->assertTrue($handler->isHandled());
 }