diff --git a/test/OPDSTest.php b/test/OPDSTest.php index 6e478e3..ee12045 100644 --- a/test/OPDSTest.php +++ b/test/OPDSTest.php @@ -44,6 +44,7 @@ class OpdsTest extends PHPUnit_Framework_TestCase $database = NULL; $_SERVER['QUERY_STRING'] = ""; + $config['cops_subtitle_default'] = "My subtitle"; $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); @@ -58,4 +59,65 @@ class OpdsTest extends PHPUnit_Framework_TestCase $_SERVER['QUERY_STRING'] = NULL; } + public function testPageIndexMultipleDatabase () + { + global $config; + $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/", + "One book" => dirname(__FILE__) . "/BaseWithOneBook/"); + $page = Base::PAGE_AUTHOR_DETAIL; + $query = NULL; + $search = NULL; + $qid = "1"; + $n = "1"; + $database = NULL; + $_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1"; + $_GET ["db"] = "0"; + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $OPDSRender = new OPDSRenderer (); + + file_put_contents (TEST_FEED, $OPDSRender->render ($currentPage)); + $this->AssertTrue ($this->opdsValidateSchema (TEST_FEED)); + } + + public function testPageAuthorsDetail () + { + global $config; + $page = Base::PAGE_AUTHOR_DETAIL; + $query = NULL; + $search = NULL; + $qid = "1"; + $n = "1"; + $database = NULL; + $_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1"; + + $config['cops_max_item_per_page'] = 2; + + // First page + + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $OPDSRender = new OPDSRenderer (); + + file_put_contents (TEST_FEED, $OPDSRender->render ($currentPage)); + $this->AssertTrue ($this->opdsValidateSchema (TEST_FEED)); + + // Second page + + $n = 2; + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + $OPDSRender = new OPDSRenderer (); + + file_put_contents (TEST_FEED, $OPDSRender->render ($currentPage)); + $this->AssertTrue ($this->opdsValidateSchema (TEST_FEED)); + + // No pagination + $config['cops_max_item_per_page'] = -1; + + } } \ No newline at end of file