From 6029355085f88c2893d3c47817d00648050e61e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 26 Nov 2013 17:01:57 +0100 Subject: [PATCH 1/3] Add a new test. re #96 --- test/pageMultidatabaseTest.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/pageMultidatabaseTest.php b/test/pageMultidatabaseTest.php index 69d8df6..59511e2 100644 --- a/test/pageMultidatabaseTest.php +++ b/test/pageMultidatabaseTest.php @@ -34,4 +34,33 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); $this->assertFalse ($currentPage->ContainsBook ()); } -} \ No newline at end of file + + 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 (); + } + +} From 39cf43cbc25f8e5ef2c0b421b6a451bbb635bbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 26 Nov 2013 17:17:22 +0100 Subject: [PATCH 2/3] Add some test of base functions. re #96 --- test/baseTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/baseTest.php b/test/baseTest.php index 7b2c21c..423930d 100644 --- a/test/baseTest.php +++ b/test/baseTest.php @@ -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 ()); + } } \ No newline at end of file From fed84c71714e4a1f8d6692fc5544338c855993de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 26 Nov 2013 17:39:17 +0100 Subject: [PATCH 3/3] Add a test for typeahead search with multiple databases. re #96 --- test/bookTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/bookTest.php b/test/bookTest.php index f23c053..05f3193 100644 --- a/test/bookTest.php +++ b/test/bookTest.php @@ -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 (); + } + } \ No newline at end of file