Beispiel #1
0
 public function testInvokeCommand__withCallableCommandHandler()
 {
     $this->bus->mapCommand('Malocher\\CqrsTest\\Integration\\Integration3\\Integration3Command', function (Integration3Command $command) {
         $command->edit();
     });
     $Integration3Command = new Integration3Command();
     $this->gate->getBus('test-integration-Integration3-bus')->invokeCommand($Integration3Command);
     $this->assertTrue($Integration3Command->isEdited());
 }
 public function exchangecurrencyAction()
 {
     try {
         $exchangeRequest = new ExchangeCurrencyRequest();
         $exchangeRequest->setQuantity(10);
         $exchangeRequest->setCurrencyCode('PLN');
         $exchangeRequest->setIdAcccountIn('1671dd26-8b07-4bb8-a009-f80049c6368f');
         $exchangeRequest->setIdAcccountReturn('1671dd26-8b07-4bb8-a009-f80049c6368f');
         $exchangeCommand = new ExchangeCurrencyCommand($exchangeRequest);
         $this->_commandBus->getBus(DomainBus::NAME)->invokeCommand($exchangeCommand);
     } catch (\Exception $e) {
         var_dump($e->getMessage());
     }
     return new ViewModel();
 }
Beispiel #3
0
 public function testGetBus_ErrorWhenNoDefaultBusIsDefined()
 {
     $this->setExpectedException('Malocher\\Cqrs\\Bus\\BusException');
     $mockBus = new MockBus(new ClassMapCommandHandlerLoader(), new ClassMapEventListenerLoader(), new ClassMapQueryHandlerLoader());
     $anotherBus = new \Malocher\CqrsTest\Coverage\Mock\Bus\MockAnotherBus(new ClassMapCommandHandlerLoader(), new ClassMapEventListenerLoader(), new ClassMapQueryHandlerLoader());
     $this->gate->attach($mockBus);
     $this->gate->attach($anotherBus);
     $this->assertEquals($this->gate->getBus(), $mockBus);
 }
Beispiel #4
0
 public function testArrayMapPublishEventMissingAdapterTrait()
 {
     $this->setExpectedException('Malocher\\Cqrs\\Bus\\BusException');
     $gate = new Gate();
     $gate->enableSystemBus();
     $gate->attach($this->bus);
     $this->bus->registerEventListener('Malocher\\CqrsTest\\Coverage\\Mock\\Event\\MockEvent', array('alias' => 'Malocher\\CqrsTest\\Coverage\\Mock\\Event\\MockEventHandler', 'method' => 'handleEvent'));
     $gate->getSystemBus()->mapCommand('Malocher\\Cqrs\\Command\\PublishEventCommand', array('alias' => 'Malocher\\CqrsTest\\Coverage\\Mock\\Command\\MockCommandHandler', 'method' => 'handleCommand'));
     $gate->getSystemBus()->registerEventListener('Malocher\\Cqrs\\Event\\EventPublishedEvent', array('alias' => 'Malocher\\CqrsTest\\Coverage\\Mock\\Event\\MockEventHandlerNoAdapter', 'method' => 'handleEvent'));
     $mockEvent = new MockEvent();
     $gate->getBus($this->bus->getName())->publishEvent($mockEvent);
 }