public static function query(Isbn $isbn) { include_once 'mysql_conn.php'; $fields = array('author', 'title', 'price', 'year', 'isbn', 'description'); $query = 'select ' . implode(', ', $fields) . ' from books where isbn="' . $isbn->toString() . '"' . ' order by price;'; $result = mysql_query($query); $book = Book::fromMySql($result); if (!$book) { return null; } while ($b = Book::fromMySql($result)) { $isComplete = true; foreach ($fields as $field) { if ($book->get($field)) { continue; } if ($b->get($field)) { $book->set($field, $b->get($field)); continue; } $isComplete = false; } if ($isComplete) { break; } } return $book; }
function testGetBook() { $isbn = new Isbn('0596002068'); $expected = new Book(array('author' => 'Ray, Randy J. and Kulchenko, Pavel', 'title' => 'Programming Web services with Perl', 'isbn' => $isbn->toString(), 'year' => '2003')); $prov = new GoogleProvider(); $prov->provideBookFor($isbn); $result = $prov->getBook(); $this->assertEquals($expected, $result); }
function testUBKarlsruhe() { $isbn13 = new Isbn('978-3897215429'); $expected = new Book(array('author' => 'Günther, Karsten', 'title' => 'LaTeX', 'year' => '2008', 'isbn' => $isbn13->toString())); $prov = new UBKarlsruheProvider(); $prov->provideBookFor($isbn13); $result = $prov->getBook(); $this->assertEquals($expected, $result); }
function setUp() { include 'mysql_conn.php'; $isbn = new Isbn('0596002068'); $book = new Book(array('author' => 'Linke, Maikel', 'title' => 'uBook Test', 'isbn' => $isbn->toString(), 'price' => '0,00', 'year' => '2011', 'description' => 'This is only a test.')); $query = 'insert into books' . ' (id, author, title, isbn, price, year, description) values' . ' (1, "' . $book->get('author') . '", "' . $book->get('title') . '", "' . $book->get('isbn') . '", "' . $book->get('price') . '", "' . $book->get('year') . '", "' . $book->get('description') . '");'; mysql_query($query); $this->isbn = $isbn; $this->book = $book; }
function testToString() { $number = 1234567890; $string = '1234567890'; $isbn = new Isbn($number); $result = $isbn->toString(); $this->assertEquals($string, $result); $this->assertTrue($result === $string); $this->assertFalse($number === $string); }
function testIsbnDbDotCom() { if (!self::$authKey) { $this->markTestSkipped('Auth key for isbndb.com required.'); } $isbn = new Isbn('0596002068'); $expected = new Book(array('author' => 'Randy J. Ray and Pavel Kulchenko', 'title' => 'Programming Web services with Perl', 'isbn' => $isbn->toString())); $prov = new IsbnDbDotComProvider(self::$authKey); $prov->provideBookFor($isbn); $result = $prov->getBook(); $this->assertEquals($expected, $result); }
protected function urlFor(Isbn $isbn) { $urlString = 'http://isbndb.com/api/books.xml?' . 'access_key=' . $this->accessKey . '&index1=isbn&value1=' . $isbn->toString(); return new HttpUrl($urlString); }
protected function urlFor(Isbn $isbn) { $this->isbn = $isbn; $urlString = 'http://books.google.com/books/feeds/volumes' . '?q=isbn%3A' . $isbn->toString(); return new HttpUrl($urlString); }
protected function urlFor(Isbn $isbn) { $urlString = 'http://www.booklooker.de/interface/search.php' . '?pid=' . $this->pid . '&medium=book&isbn=' . $isbn->toString(); return new HttpUrl($urlString); }
protected function urlFor(Isbn $isbn) { $this->isbn = $isbn; $urlString = 'http://www.ubka.uni-karlsruhe.de/hylib-bin/suche.cgi' . '?opacdb=UBKA_OPAC&simple_search=isbn%3D' . $isbn->toString() . '&raw=1&einzeltreffer=kurz'; return new HttpUrl($urlString); }