public function testAddBookHandlerWillCallStoreOnRepository() { $id = Uuid::createNew(); $title = 'foo'; $authors = [new AddAuthor($id, 'first', 'last', -1)]; $isbn = 'isbn'; $command = new AddBook($id, $authors, $title, $isbn); $book = Book::add($command->getId(), $command->getAuthors(), $command->getTitle(), $command->getISBN()); $repository = $this->getMockBuilder(Repository::class)->disableOriginalConstructor()->getMock(); $repository->expects(self::once())->method('store')->with($book); $handler = new AddBookHandler($repository); $handler->handle($command); }
/** * @param AddBook $command */ private function handleAddBook(AddBook $command) { $book = Book::add($command->getId(), $command->getAuthors(), $command->getTitle(), $command->getISBN()); $this->repository->store($book); }