public function testAddBookActionSendsAddBookCommand() { $this->commandBus->expects(self::once())->method('send')->will(self::returnCallback(function (Command $command) { self::assertInstanceOf(AddBook::class, $command); })); $book = new Book(Uuid::createFromValue(null), new Authors([new Author('first', 'last')]), 'title', 'isbn', true, -1); $resource = BookResource::createFromReadModel($book); $this->service->expects(self::once())->method('getBook')->will(self::returnValue($book)); $controller = new BooksController($this->viewBuilder, $this->service, $this->commandBus); $controller->addBookAction($resource); }
public function testCreateFromReadModelMapsDocumentToResource() { $id = Uuid::createNew(); $authors = new Authors(); $title = 'title'; $isbn = 'isbn'; $available = true; $version = 1; $document = new BookDocument($id, $authors, $title, $isbn, $available, $version); $resource = BookResource::createFromReadModel($document); self::assertEquals($id, $resource->getId()); self::assertEquals($title, $resource->getTitle()); self::assertEquals($isbn, $resource->getISBN()); self::assertEquals($available, $resource->isAvailable()); }