Merge
This commit is contained in:
commit
780a990ea0
|
@ -42,4 +42,19 @@ class BaseTest extends PHPUnit_Framework_TestCase
|
|||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
|
||||
localize ("authors.title", -1, true);
|
||||
}
|
||||
|
||||
public function testBaseFunction () {
|
||||
global $config;
|
||||
|
||||
$this->assertFalse (Base::isMultipleDatabaseEnabled ());
|
||||
$this->assertEquals (array ("" => dirname(__FILE__) . "/BaseWithSomeBooks/"), Base::getDbList ());
|
||||
|
||||
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||
|
||||
$this->assertTrue (Base::isMultipleDatabaseEnabled ());
|
||||
$this->assertEquals ("Some books", Base::getDbName (0));
|
||||
$this->assertEquals ("One book", Base::getDbName (1));
|
||||
$this->assertEquals ($config['calibre_directory'], Base::getDbList ());
|
||||
}
|
||||
}
|
|
@ -172,4 +172,30 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$_GET["search"] = NULL;
|
||||
}
|
||||
|
||||
public function testTypeaheadSearchMultiDatabase ()
|
||||
{
|
||||
global $config;
|
||||
$_GET["query"] = "art";
|
||||
$_GET["search"] = "1";
|
||||
$_GET["multi"] = "1";
|
||||
|
||||
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||
|
||||
$array = getJson ();
|
||||
|
||||
$this->assertCount (4, $array);
|
||||
$this->assertEquals ("Some books", $array[0]["title"]);
|
||||
$this->assertEquals ("No book", $array[1]["title"]);
|
||||
$this->assertEquals ("One book", $array[2]["title"]);
|
||||
$this->assertEquals ("1 book", $array[3]["title"]);
|
||||
|
||||
$_GET["query"] = NULL;
|
||||
$_GET["search"] = NULL;
|
||||
}
|
||||
|
||||
public function tearDown () {
|
||||
Base::clearDb ();
|
||||
}
|
||||
|
||||
}
|
|
@ -34,4 +34,33 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
}
|
||||
|
||||
public function testPageSearchXXX ()
|
||||
{
|
||||
global $config;
|
||||
$config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
|
||||
"One book" => dirname(__FILE__) . "/BaseWithOneBook/");
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$query = "art";
|
||||
$search = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$database = NULL;
|
||||
|
||||
$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);
|
||||
$this->assertEquals ("10 books", $currentPage->entryArray [0]->content);
|
||||
$this->assertEquals ("One book", $currentPage->entryArray [1]->title);
|
||||
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass () {
|
||||
Base::clearDb ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue