Ejemplo n.º 1
0
 /**
  *
  */
 public function __construct()
 {
     // The gate manages the bus system
     $this->gate = new Gate();
     // Create a bus and attach it to the gate
     $this->bus = new Iteration4Bus();
     $this->bus->setCommandHandlerLoader(new ClassMapCommandHandlerLoader());
     $this->bus->setEventListenerLoader(new ClassMapEventListenerLoader());
     $this->bus->setQueryHandlerLoader(new ClassMapQueryHandlerLoader());
     $this->gate->attach($this->bus);
     // Use of AnnotationAdapter, adapters always us pipe
     $adapter = new AnnotationAdapter();
     $adapter->pipe($this->bus, array('Iteration\\Iteration4\\Iteration4Handler'));
     // Enable the SystemBus and pipe it to some Monitoring
     $this->gate->enableSystemBus();
     $adapter->pipe($this->gate->getSystemBus(), array('Iteration\\Iteration4\\Iteration4Monitor'));
     // Send a command to the bus
     // Iteration4Handler::editCommand is mapped against this command and will be called
     $this->bus->invokeCommand(new Iteration4Command('Hello'));
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function test4()
 {
     $this->adapter->pipe($this->bus, array('Malocher\\CqrsTest\\Integration\\Integration2\\Integration2Handler'));
     $event = new Integration2Event();
     $event->callback = function (Integration2Handler $returnedHandler, Integration2Event $returnedEvent, $returnedEventIsEdited) {
         $this->assertInstanceOf('Malocher\\CqrsTest\\Integration\\Integration2\\Integration2Handler', $returnedHandler);
         $this->assertInstanceOf('Malocher\\CqrsTest\\Integration\\Integration2\\Integration2Event', $returnedEvent);
         $this->assertTrue($returnedEventIsEdited);
         $this->assertTrue(true);
     };
     $this->bus->publishEvent($event);
 }
Ejemplo n.º 3
0
 /**
  *
  */
 public function __construct()
 {
     // The gate manages the bus system
     $this->gate = new Gate();
     // Create a bus and attach it to the gate
     $this->bus = new Iteration3Bus();
     $this->bus->setCommandHandlerLoader(new ClassMapCommandHandlerLoader());
     $this->bus->setEventListenerLoader(new ClassMapEventListenerLoader());
     $this->bus->setQueryHandlerLoader(new ClassMapQueryHandlerLoader());
     $this->gate->attach($this->bus);
     // Use of AnnotationAdapter, adapters always us pipe
     $adapter = new AnnotationAdapter();
     $adapter->pipe($this->bus, array('Iteration\\Iteration3\\Iteration3Handler'));
     // See how this affects Iteration3Handler
     // Send a command to the bus
     // Iteration3Handler::editCommand is mapped against this command and will be called
     $this->bus->invokeCommand(new Iteration3Command('Hello'));
 }
Ejemplo n.º 4
0
 public function testPublishEventHandlerNoAdapter()
 {
     $this->setExpectedException('Malocher\\Cqrs\\Bus\\BusException');
     $this->bus->setGate(new Gate());
     $adapter = new AnnotationAdapter();
     $adapter->pipe($this->bus, array('Malocher\\CqrsTest\\Coverage\\Mock\\Event\\MockEventHandlerNoAdapter'));
     $mockEvent = new MockEvent();
     $mockEvent->callback = function ($isEdited) {
     };
     $this->bus->publishEvent($mockEvent);
     $this->assertEquals(true, $mockEvent->isEdited());
 }
Ejemplo n.º 5
0
 public function testPipeWrongAnnotationsEventHandler()
 {
     $this->setExpectedException('Malocher\\Cqrs\\Adapter\\AdapterException');
     $configuration = array('Malocher\\CqrsTest\\Coverage\\Mock\\Event\\MockEventHandlerWrongAnnotations');
     $this->adapter->pipe($this->bus, $configuration);
 }