public function testCreateActionCreatesUserIfNotExists()
 {
     $id = Uuid::createNew();
     $user = new User($id, 'user', 'email', 'name', 0);
     $resource = UserResource::createFromReadModel($user);
     $this->commandBus->expects(self::once())->method('send')->will(self::returnCallback(function (Command $command) {
         self::assertInstanceOf(CreateUser::class, $command);
     }));
     $this->service->expects(self::once())->method('getUser')->will(self::returnValue($user));
     $controller = new UsersController($this->viewBuilder, $this->service, $this->commandBus);
     $view = $controller->createAction($resource);
     self::assertEquals(201, $view->getStatusCode());
 }
 public function testReturnBookSendsReturnBookCommand()
 {
     $this->commandBus->expects(self::once())->method('send')->will(self::returnCallback(function (Command $command) {
         self::assertInstanceOf(ReturnBook::class, $command);
     }));
     $id = Uuid::createNew();
     $controller = new BooksController($this->viewBuilder, $this->service, $this->commandBus);
     $controller->returnBookAction($id, 0);
 }