From fc80875d342359739bb40e60ca4fb55f8abee59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 15 Oct 2013 08:31:26 +0200 Subject: [PATCH] Test typeahead search. re #96 --- test/bookTest.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/bookTest.php b/test/bookTest.php index 7dff03d..45986ad 100644 --- a/test/bookTest.php +++ b/test/bookTest.php @@ -128,4 +128,42 @@ class BookTest extends PHPUnit_Framework_TestCase $this->assertEquals ("", $book->getRating ()); } + public function testTypeaheadSearch () + { + $_GET["query"] = "fic"; + $_GET["search"] = "1"; + + $array = getJson (); + + $this->assertCount (3, $array); + $this->assertEquals ("2 tags", $array[0]["title"]); + $this->assertEquals ("Fiction", $array[1]["title"]); + $this->assertEquals ("Science Fiction", $array[2]["title"]); + + $_GET["query"] = "car"; + $_GET["search"] = "1"; + + $array = getJson (); + + $this->assertCount (4, $array); + $this->assertEquals ("1 book", $array[0]["title"]); + $this->assertEquals ("A Study in Scarlet", $array[1]["title"]); + $this->assertEquals ("1 author", $array[2]["title"]); + $this->assertEquals ("Carroll, Lewis", $array[3]["title"]); + + $_GET["query"] = "art"; + $_GET["search"] = "1"; + + $array = getJson (); + + $this->assertCount (4, $array); + $this->assertEquals ("1 author", $array[0]["title"]); + $this->assertEquals ("Doyle, Arthur Conan", $array[1]["title"]); + $this->assertEquals ("1 series", $array[2]["title"]); + $this->assertEquals ("D'Artagnan Romances", $array[3]["title"]); + + $_GET["query"] = NULL; + $_GET["search"] = NULL; + } + } \ No newline at end of file