Add a test in multiple database. failing for the moment. re #96

This commit is contained in:
Sébastien Lucas 2013-10-24 21:33:49 +02:00
parent e3b2a20423
commit 5576d81684

View file

@ -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;
}
}