2013-12-05 11:50:53 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* COPS (Calibre OPDS PHP Server) test file
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author Sébastien Lucas <sebastien@slucas.fr>
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once (dirname(__FILE__) . "/config_test.php");
|
|
|
|
require_once (dirname(__FILE__) . "/../book.php");
|
|
|
|
|
|
|
|
class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
2013-12-05 11:52:51 +02:00
|
|
|
{
|
2013-12-05 11:50:53 +02:00
|
|
|
public function testPageIndex ()
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
|
|
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
|
|
|
$page = Base::PAGE_INDEX;
|
|
|
|
$query = NULL;
|
|
|
|
$qid = NULL;
|
|
|
|
$n = "1";
|
2013-12-05 11:52:51 +02:00
|
|
|
|
2013-12-05 11:50:53 +02:00
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
|
|
|
$currentPage->InitializeContent ();
|
2013-12-05 11:52:51 +02:00
|
|
|
|
2013-12-05 11:50:53 +02:00
|
|
|
$this->assertEquals ($config['cops_title_default'], $currentPage->title);
|
|
|
|
$this->assertCount (2, $currentPage->entryArray);
|
|
|
|
$this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
|
2014-04-29 16:16:25 +03:00
|
|
|
$this->assertEquals ("15 books", $currentPage->entryArray [0]->content);
|
2013-12-05 11:50:53 +02:00
|
|
|
$this->assertEquals ("One book", $currentPage->entryArray [1]->title);
|
|
|
|
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
|
|
|
$this->assertFalse ($currentPage->ContainsBook ());
|
|
|
|
}
|
2013-12-05 11:52:51 +02:00
|
|
|
|
2013-12-24 12:36:05 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider providerSearch
|
|
|
|
*/
|
|
|
|
public function testPageSearchXXX ($maxItem)
|
2013-12-05 11:50:53 +02:00
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
|
|
|
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY;
|
|
|
|
$query = "art";
|
|
|
|
$qid = NULL;
|
|
|
|
$n = "1";
|
2013-12-05 11:52:51 +02:00
|
|
|
|
2013-12-07 22:17:38 +02:00
|
|
|
// Issue 124
|
2013-12-24 12:36:05 +02:00
|
|
|
$config['cops_max_item_per_page'] = $maxItem;
|
2013-12-07 22:17:38 +02:00
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
|
|
|
$currentPage->InitializeContent ();
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEquals ("Search result for *art*", $currentPage->title);
|
|
|
|
$this->assertCount (2, $currentPage->entryArray);
|
|
|
|
$this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
|
2014-04-29 16:16:25 +03:00
|
|
|
$this->assertEquals ("11 books", $currentPage->entryArray [0]->content);
|
2013-12-07 22:17:38 +02:00
|
|
|
$this->assertEquals ("One book", $currentPage->entryArray [1]->title);
|
|
|
|
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
|
|
|
$this->assertFalse ($currentPage->ContainsBook ());
|
2013-12-24 12:36:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerSearch ()
|
|
|
|
{
|
|
|
|
return array (
|
|
|
|
array (2),
|
|
|
|
array (-1)
|
|
|
|
);
|
2013-12-05 11:50:53 +02:00
|
|
|
}
|
2013-12-05 11:52:51 +02:00
|
|
|
|
2013-12-05 11:50:53 +02:00
|
|
|
public static function tearDownAfterClass () {
|
|
|
|
Base::clearDb ();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|