public function __construct()
 {
     parent::__construct();
     $this->bus = $bus = new QueryBus();
     $bus->register('Borobudur\\Cqrs\\Test\\AllMovieQuery', 'Borobudur\\Cqrs\\Test\\AllMovieQueryHandler');
     $bus->register('Borobudur\\Cqrs\\Test\\DetailMovieQuery', 'Borobudur\\Cqrs\\Test\\DetailMovieQueryHandler');
     /** @var Pdo $storage */
     $this->storage = $storage = StorageManager::instance('mysql', 'localhost', 5432, 'app', 'root');
     self::$repository = new MovieRepository($this->storage);
     $storage->exec('DROP TABLE IF EXISTS Movie');
     $storage->exec('
         CREATE TABLE Movie(
             id CHAR(13) PRIMARY KEY,
             name VARCHAR(100) NOT NULL,
             schedule DATETIME NOT NULL,
             price INT NULL,
             buyers INT NULL,
             deleted INT(1) NOT NULL
         );
     ');
     $data = array(array('name' => 'San Andreas', 'schedule' => new \DateTime(), 'price' => 25000, 'buyers' => 5), array('name' => 'Godzila', 'schedule' => new \DateTime(), 'price' => 30000, 'buyers' => 1), array('name' => 'Social Network', 'schedule' => new \DateTime('+1 month'), 'price' => 50000, 'buyers' => 6), array('name' => 'Pixed', 'schedule' => new \DateTime('+1 day'), 'price' => 100000, 'buyers' => 10), array('name' => 'Ace ventura', 'schedule' => new \DateTime('-1 month'), 'price' => 80000, 'buyers' => 3));
     foreach ($data as $record) {
         self::$repository->save(new MovieReadModel(uniqid(), $record['name'], $record['schedule']->format('Y-m-d H:i:s'), $record['price'], $record['buyers']));
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function dispatch(MessageInterface $query)
 {
     $this->autoRegister($query);
     $this->validator->validateWithAnnotation($query);
     $this->validator->assertValid();
     return parent::dispatch($query);
 }