Better testing of Data object

This commit is contained in:
Sébastien Lucas 2013-12-05 10:21:46 +01:00
parent 76b7089028
commit 980446d9c6

View file

@ -179,12 +179,26 @@ class BookTest extends PHPUnit_Framework_TestCase
public function testGetDataById () public function testGetDataById ()
{ {
global $config;
// Get Alice MOBI=>17, PDF=>19, EPUB=>20 // Get Alice MOBI=>17, PDF=>19, EPUB=>20
$book = Book::getBookById(17); $book = Book::getBookById(17);
$data = $book->getDataById (17); $data = $book->getDataById (17);
$this->assertEquals ("MOBI", $data->format); $this->assertEquals ("MOBI", $data->format);
$data = $book->getDataById (20); $data = $book->getDataById (20);
$this->assertEquals ("EPUB", $data->format); $this->assertEquals ("EPUB", $data->format);
$this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.epub", $data->getUpdatedFilenameEpub ());
$this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.kepub.epub", $data->getUpdatedFilenameKepub ());
$this->assertEquals (dirname(__FILE__) . "/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub", $data->getLocalPath ());
$config['cops_use_url_rewriting'] = "1";
$config['cops_provide_kepub'] = "1";
$_SERVER["HTTP_USER_AGENT"] = "Kobo";
$this->assertEquals ("download/20/Carroll%2C+Lewis+-+Alice%27s+Adventures+in+Wonderland.kepub.epub", $data->getHtmlLink ());
$_SERVER["HTTP_USER_AGENT"] = "Firefox";
$this->assertEquals ("download/20/Alice%27s+Adventures+in+Wonderland+-+Lewis+Carroll.epub", $data->getHtmlLink ());
$config['cops_use_url_rewriting'] = "0";
$this->assertEquals ("fetch.php?data=20&type=epub&id=17", $data->getHtmlLink ());
} }
public function testTypeaheadSearch () public function testTypeaheadSearch ()