public function testAddAuthorActionSendsAddAuthorCommand() { $this->commandBus->expects(self::once())->method('send')->will(self::returnCallback(function (Command $command) { self::assertInstanceOf(AddAuthor::class, $command); })); $id = Uuid::createNew(); $book = new Book($id, new Authors(), 'title', 'isbn', true, -1); $this->service->expects(self::atLeastOnce())->method('getBook')->will(self::returnValue($book)); $author = new Author('first', 'last'); $resource = AuthorResource::createFromReadModel($author); $controller = new BooksController($this->viewBuilder, $this->service, $this->commandBus); $controller->addAuthorAction($id, $resource, -1); }
public function testApplyConverterOnVersionWithInvalidVersionThrowsException() { self::setExpectedException(PreconditionFailedHttpException::class); $id = Uuid::createNew(); $version = 1; $book = new BookReadModel($id, new Authors(), 'title', 'isbn', true, $version); $request = Request::createFromGlobals(); $request->headers->set('if-none-match', 'foo'); $request->attributes->set('id', $id); $this->bookService->expects(self::once())->method('getBook')->with($id)->will(self::returnValue($book)); $this->configuration->expects(self::atLeastOnce())->method('getName')->will(self::returnValue('version')); $this->configuration->expects(self::once())->method('getOptions')->will(self::returnValue(['id' => 'id'])); $this->configuration->expects(self::once())->method('getClass')->will(self::returnValue(BookReadModel::class)); $converter = new ParamConverter($this->bookService, $this->userService); $converter->apply($request, $this->configuration); }