Esempio n. 1
0
 public function test_that_query_is_handled_by_pipeline()
 {
     $handler = new UserByEmailHandler();
     $this->queryMap->registerHandlers([UserByEmailQuery::class => $handler]);
     $query = new UserByEmailQuery('*****@*****.**');
     $user = $this->pipeline->fetch($query);
     $this->assertTrue($this->queryMap->hasHandler(UserByEmailQuery::class) && $this->logHandler->hasInfoThatContains(sprintf('Query received {%s}', ClassName::canonical(UserByEmailQuery::class))) && $this->logHandler->hasInfoThatContains(sprintf('Query handled {%s}', ClassName::canonical(UserByEmailQuery::class))) && $user['email'] === '*****@*****.**');
 }
Esempio n. 2
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());
 }
Esempio n. 3
0
 public function test_that_event_is_logged_by_subscriber()
 {
     $event = new UserRegisteredEvent('*****@*****.**', 'James', 'Smith', 'D');
     $this->dispatcher->dispatch($event);
     $this->assertTrue($this->logHandler->hasInfoThatContains(sprintf('Event dispatched {%s}', ClassName::canonical(UserRegisteredEvent::class))));
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function serialize(Serializable $object) : string
 {
     $data = ['@' => ClassName::canonical($object), '$' => $object->serialize()];
     return json_encode($data, JSON_UNESCAPED_SLASHES);
 }
Esempio n. 5
0
 /**
  * Creates instance from an object or class name
  *
  * @param object|string $object An object, fully qualified class name, or
  *                              canonical class name
  *
  * @return Type
  */
 public static function create($object) : Type
 {
     return new static(ClassName::canonical($object));
 }
Esempio n. 6
0
 public function test_that_canonical_returns_expected_value()
 {
     $expected = 'Novuso.System.Utility.ClassName';
     $className = 'Novuso\\System\\Utility\\ClassName';
     $this->assertSame($expected, ClassName::canonical($className));
 }