/** * {@inheritdoc } * @param Isbn $isbn to search for * @return Book containing found data */ public static function query(Isbn $isbn) { $localProvider = new LocalIsbnProvider(); $book = $localProvider->query($isbn); if ($book) { return $book; } $providers = HttpProviders::createProviders(); foreach ($providers as $i => $p) { $p->provideBookFor($isbn); } foreach ($providers as $i => $p) { $book = $p->getBook(); if ($book) { return $book; } } return new Book(array('isbn' => $isbn->toString())); }
function testQuery() { $prov = new LocalIsbnProvider(); $result = $prov->query($this->isbn); $this->assertEquals($this->book, $result); }