Esempio n. 1
0
 /**
  * @test
  */
 public function it_should_return_handlers()
 {
     $commandBus = new CommandBus();
     $handler = new CommandHandler_stub();
     $commandToHandle = 'HCLabs\\Bills\\Test\\Command\\CommandHandler_stub';
     $commandBus->addHandler($handler, $commandToHandle);
     $this->assertSame([$commandToHandle => $handler], $commandBus->getHandlers());
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function it_should_handle_bill_already_paid_exception_and_throw_an_http_exception()
 {
     $this->setExpectedException('\\Symfony\\Component\\HttpKernel\\Exception\\HttpException');
     $dispatcherMock = $this->getMockForAbstractClass('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $repository = new BillRepository();
     $commandBus = new CommandBus();
     $handler = new PayBillCommandHandler($dispatcherMock, $repository);
     $commandBus->addHandler($handler, 'HCLabs\\Bills\\Command\\Scenario\\PayBill\\PayBillCommand');
     $controller = new BillController($commandBus);
     $bill = $this->getBill();
     $bill->pay();
     $controller->payAction($bill);
 }