/**
  * @event Malocher\Cqrs\Event\CommandInvokedEvent
  * @param CommandInvokedEvent $event
  */
 public function commandInvokedHandler(CommandInvokedEvent $event)
 {
     print "---- monitoring start -----\n";
     print sprintf("CommandInvokedEvent published by %s on %s \n", $event->getMessageClass(), $event->getBusName());
     print sprintf("id:%s, edited:%s, ts:%s, version:%s, payload:%s \n", $event->getMessageVars()['id'], $event->getMessageVars()['edited'], $event->getMessageVars()['timestamp'], $event->getMessageVars()['version'], $event->getMessageVars()['payload']);
     print "---- monitoring ends ------\n";
 }
Beispiel #2
0
 public function testClosureInvokeCommand()
 {
     $gate = new Gate();
     $gate->enableSystemBus();
     $gate->attach($this->bus);
     $this->bus->mapCommand('Malocher\\CqrsTest\\Coverage\\Mock\\Command\\MockCommand', function (MockCommand $command) {
         $command->edit();
     });
     $gate->getSystemBus()->mapCommand('Malocher\\Cqrs\\Command\\InvokeCommandCommand', function (InvokeCommandCommand $command) {
         $this->invokeCommandCommand = $command;
     });
     $gate->getSystemBus()->registerEventListener('Malocher\\Cqrs\\Event\\CommandInvokedEvent', function (CommandInvokedEvent $event) {
         $this->commandInvokedEvent = $event;
     });
     $mockCommand = new MockCommand();
     $gate->getBus($this->bus->getName())->invokeCommand($mockCommand);
     $this->assertEquals(true, $mockCommand->isEdited());
     $this->assertInstanceOf('Malocher\\Cqrs\\Command\\InvokeCommandCommand', $this->invokeCommandCommand);
     $this->assertInstanceOf('Malocher\\Cqrs\\Event\\CommandInvokedEvent', $this->commandInvokedEvent);
     $this->assertEquals('Malocher\\CqrsTest\\Coverage\\Mock\\Command\\MockCommand', $this->invokeCommandCommand->getMessageClass());
     $this->assertEquals('Malocher\\CqrsTest\\Coverage\\Mock\\Command\\MockCommand', $this->commandInvokedEvent->getMessageClass());
 }