From 980446d9c6784e9689154a40c1ed42ab4262b209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Thu, 5 Dec 2013 10:21:46 +0100 Subject: [PATCH] Better testing of Data object --- test/bookTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/bookTest.php b/test/bookTest.php index b09ac70..5ffc3b1 100644 --- a/test/bookTest.php +++ b/test/bookTest.php @@ -179,12 +179,26 @@ class BookTest extends PHPUnit_Framework_TestCase public function testGetDataById () { + global $config; + // Get Alice MOBI=>17, PDF=>19, EPUB=>20 $book = Book::getBookById(17); $data = $book->getDataById (17); $this->assertEquals ("MOBI", $data->format); $data = $book->getDataById (20); $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 ()