function it_returns_exactly_one_result_when_searching_by_exact_isbn_and_it_matches(BookInterface $book)
 {
     $isbn = new Isbn('978-1-56619-909-4');
     $book->isbn()->willReturn($isbn);
     $this->add($book);
     $this->searchByIsbn($isbn)->shouldBe(SearchResults::fromArrayOfBooks(array($book)));
 }
 function it_renders_empty_results_by_default(Request $request, ParameterBag $requestQueryParameters, EngineInterface $templatingEngine, Response $response)
 {
     $request->query = $requestQueryParameters;
     $requestQueryParameters->has('isbn')->willReturn(false);
     $templatingEngine->renderResponse('search.html.twig', ['results' => SearchResults::asEmpty()])->willReturn($response);
     $this->searchByIsbnAction($request)->shouldReturn($response);
 }
 function it_searches_book_by_isbn_number(BookInterface $book, ObjectRepository $doctrineRepository)
 {
     $isbn = new Isbn('978-1-56619-909-4');
     $doctrineRepository->findOneBy(array('isbn.number' => $isbn))->willReturn($book);
     $this->searchByIsbn($isbn)->shouldBeLike(SearchResults::fromArrayOfBooks(array($book->getWrappedObject())));
     $doctrineRepository->findOneBy(array('isbn.number' => $isbn))->willReturn(null);
     $this->searchByIsbn($isbn)->shouldBeLike(SearchResults::asEmpty());
 }
 public function searchByIsbnAction(Request $request)
 {
     $searchResults = SearchResults::asEmpty();
     if ($request->query->has('isbn')) {
         $searchResults = $this->library->searchByIsbn(new Isbn($request->query->get('isbn')));
     }
     return $this->templatingEngine->renderResponse('search.html.twig', ['results' => $searchResults]);
 }
 public function searchByIsbn(Isbn $isbn)
 {
     $book = $this->doctrineRepository->findOneBy(array('isbn.number' => $isbn));
     if (null === $book) {
         return SearchResults::asEmpty();
     }
     return SearchResults::fromArrayOfBooks(array($book));
 }
 public function searchByIsbn(Isbn $isbn)
 {
     $books = $this->hasBookWithIsbn($isbn) ? array($this->books[(string) $isbn]) : array();
     return SearchResults::fromArrayOfBooks($books);
 }
 public function __construct()
 {
     $this->library = new InMemoryLibrary();
     $this->currentSearchResults = SearchResults::asEmpty();
 }