Remove trailing spaces
This commit is contained in:
parent
9f5f00e114
commit
0f09ef5f8c
21 changed files with 478 additions and 478 deletions
|
@ -55,7 +55,7 @@ class Cops extends Sauce\Sausage\WebDriverTestCase
|
|||
'platform' => 'Linux'
|
||||
)
|
||||
)
|
||||
// run Mobile Browser on Android
|
||||
// run Mobile Browser on Android
|
||||
// array(
|
||||
// 'browserName' => 'Android',
|
||||
// 'desiredCapabilities' => array(
|
||||
|
@ -63,7 +63,7 @@ class Cops extends Sauce\Sausage\WebDriverTestCase
|
|||
// 'platform' => 'Linux',
|
||||
// )
|
||||
// )
|
||||
|
||||
|
||||
// run Chrome locally
|
||||
//array(
|
||||
//'browserName' => 'chrome',
|
||||
|
@ -81,7 +81,7 @@ class Cops extends Sauce\Sausage\WebDriverTestCase
|
|||
}
|
||||
parent::setUp ();
|
||||
}
|
||||
|
||||
|
||||
public function setUpPage()
|
||||
{
|
||||
if (isset ($_SERVER["TRAVIS_JOB_NUMBER"])) {
|
||||
|
@ -89,25 +89,25 @@ class Cops extends Sauce\Sausage\WebDriverTestCase
|
|||
} else {
|
||||
$this->url('http://cops-demo.slucas.fr/index.php');
|
||||
}
|
||||
|
||||
|
||||
$driver = $this;
|
||||
$title_test = function($value) use ($driver) {
|
||||
$text = $driver->byXPath('//h1')->text ();
|
||||
return $text == $value;
|
||||
};
|
||||
|
||||
|
||||
$this->spinAssert("Home Title", $title_test, [ "COPS DEMO" ]);
|
||||
}
|
||||
|
||||
|
||||
public function string_to_ascii($string)
|
||||
{
|
||||
$ascii = NULL;
|
||||
|
||||
|
||||
for ($i = 0; $i < strlen($string); $i++)
|
||||
{
|
||||
$ascii += ord($string[$i]);
|
||||
}
|
||||
|
||||
|
||||
return mb_detect_encoding($string) . "X" . $ascii;
|
||||
}
|
||||
|
||||
|
@ -121,19 +121,19 @@ class Cops extends Sauce\Sausage\WebDriverTestCase
|
|||
|
||||
$author = $this->byXPath ('//h2[contains(text(), "Authors")]');
|
||||
$author->click ();
|
||||
|
||||
|
||||
$this->spinAssert("Author Title", $title_test, [ "AUTHORS" ]);
|
||||
}
|
||||
|
||||
|
||||
public function testCog()
|
||||
{
|
||||
{
|
||||
$cog = $this->byId ("searchImage");
|
||||
|
||||
|
||||
$search = $this->byName ("query");
|
||||
$this->assertFalse ($search->displayed ());
|
||||
|
||||
|
||||
$cog->click ();
|
||||
|
||||
|
||||
$search = $this->byName ("query");
|
||||
$this->assertTrue ($search->displayed ());
|
||||
}
|
||||
|
|
|
@ -10,42 +10,42 @@ require_once (dirname(__FILE__) . "/config_test.php");
|
|||
require_once (dirname(__FILE__) . "/../base.php");
|
||||
|
||||
class BaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
{
|
||||
public function testAddURLParameter ()
|
||||
{
|
||||
$this->assertEquals ("?db=0", addURLParameter ("?", "db", "0"));
|
||||
$this->assertEquals ("?key=value&db=0", addURLParameter ("?key=value", "db", "0"));
|
||||
$this->assertEquals ("?key=value&otherKey=&db=0", addURLParameter ("?key=value&otherKey", "db", "0"));
|
||||
}
|
||||
|
||||
|
||||
public function testLocalize ()
|
||||
{
|
||||
$this->assertEquals ("Authors", localize ("authors.title"));
|
||||
|
||||
|
||||
$this->assertEquals ("unknow.key", localize ("unknow.key"));
|
||||
}
|
||||
|
||||
|
||||
public function testLocalizeFr ()
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3";
|
||||
$this->assertEquals ("Auteurs", localize ("authors.title", -1, true));
|
||||
|
||||
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en";
|
||||
localize ("authors.title", -1, true);
|
||||
}
|
||||
|
||||
|
||||
public function testLocalizeUnknown ()
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = "aa";
|
||||
$this->assertEquals ("Authors", localize ("authors.title", -1, true));
|
||||
|
||||
|
||||
$_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 ());
|
||||
|
||||
|
|
|
@ -11,70 +11,70 @@ require_once (dirname(__FILE__) . "/../book.php");
|
|||
|
||||
/*
|
||||
Publishers:
|
||||
id:2 (2 books) Macmillan and Co. London: Lewis Caroll
|
||||
id:3 (2 books) D. Appleton and Company Alexander Dumas
|
||||
id:4 (1 book) Macmillan Publishers USA: Jack London
|
||||
id:5 (1 book) Pierson's Magazine: H. G. Wells
|
||||
id:2 (2 books) Macmillan and Co. London: Lewis Caroll
|
||||
id:3 (2 books) D. Appleton and Company Alexander Dumas
|
||||
id:4 (1 book) Macmillan Publishers USA: Jack London
|
||||
id:5 (1 book) Pierson's Magazine: H. G. Wells
|
||||
id:6 (8 books) Strand Magazine: Arthur Conan Doyle
|
||||
*/
|
||||
|
||||
class BookTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
{
|
||||
public function testGetBookCount ()
|
||||
{
|
||||
$this->assertEquals (14, Book::getBookCount ());
|
||||
}
|
||||
|
||||
|
||||
public function testGetCount ()
|
||||
{
|
||||
$entryArray = Book::getCount ();
|
||||
$this->assertEquals (2, count($entryArray));
|
||||
|
||||
|
||||
$entryAllBooks = $entryArray [0];
|
||||
$this->assertEquals ("Alphabetical index of the 14 books", $entryAllBooks->content);
|
||||
|
||||
|
||||
$entryRecentBooks = $entryArray [1];
|
||||
$this->assertEquals ("50 most recent books", $entryRecentBooks->content);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testGetCountRecent ()
|
||||
{
|
||||
global $config;
|
||||
$config['cops_recentbooks_limit'] = 0;
|
||||
$config['cops_recentbooks_limit'] = 0;
|
||||
$entryArray = Book::getCount ();
|
||||
|
||||
|
||||
$this->assertEquals (1, count($entryArray));
|
||||
|
||||
$config['cops_recentbooks_limit'] = 2;
|
||||
|
||||
$config['cops_recentbooks_limit'] = 2;
|
||||
$entryArray = Book::getCount ();
|
||||
|
||||
|
||||
$entryRecentBooks = $entryArray [1];
|
||||
$this->assertEquals ("2 most recent books", $entryRecentBooks->content);
|
||||
|
||||
$config['cops_recentbooks_limit'] = 50;
|
||||
|
||||
$config['cops_recentbooks_limit'] = 50;
|
||||
}
|
||||
|
||||
|
||||
public function testGetBooksByAuthor ()
|
||||
{
|
||||
// All book by Arthur Conan Doyle
|
||||
global $config;
|
||||
|
||||
|
||||
$config['cops_max_item_per_page'] = 5;
|
||||
list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, 1);
|
||||
$this->assertEquals (5, count($entryArray));
|
||||
$this->assertEquals (8, $totalNumber);
|
||||
|
||||
|
||||
list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, 2);
|
||||
$this->assertEquals (3, count($entryArray));
|
||||
$this->assertEquals (8, $totalNumber);
|
||||
|
||||
|
||||
$config['cops_max_item_per_page'] = -1;
|
||||
list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, -1);
|
||||
$this->assertEquals (8, count($entryArray));
|
||||
$this->assertEquals (-1, $totalNumber);
|
||||
}
|
||||
|
||||
|
||||
public function testGetBooksBySeries ()
|
||||
{
|
||||
// All book from the Sherlock Holmes series
|
||||
|
@ -82,10 +82,10 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals (7, count($entryArray));
|
||||
$this->assertEquals (-1, $totalNumber);
|
||||
}
|
||||
|
||||
|
||||
public function testGetBooksByPublisher ()
|
||||
{
|
||||
// All books from Strand Magazine
|
||||
// All books from Strand Magazine
|
||||
list ($entryArray, $totalNumber) = Book::getBooksByPublisher (6, -1);
|
||||
$this->assertEquals (8, count($entryArray));
|
||||
$this->assertEquals (-1, $totalNumber);
|
||||
|
@ -98,7 +98,7 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals (14, count($entryArray));
|
||||
$this->assertEquals (-1, $totalNumber);
|
||||
}
|
||||
|
||||
|
||||
public function testGetBooksByLanguage ()
|
||||
{
|
||||
// All english book (= all books)
|
||||
|
@ -106,14 +106,14 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals (14, count($entryArray));
|
||||
$this->assertEquals (-1, $totalNumber);
|
||||
}
|
||||
|
||||
|
||||
public function testGetAllBooks ()
|
||||
{
|
||||
// All books by first letter
|
||||
$entryArray = Book::getAllBooks ();
|
||||
$this->assertCount (9, $entryArray);
|
||||
}
|
||||
|
||||
|
||||
public function testGetBooksByStartingLetter ()
|
||||
{
|
||||
// All books by first letter
|
||||
|
@ -121,26 +121,26 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals (-1, $totalNumber);
|
||||
$this->assertCount (3, $entryArray);
|
||||
}
|
||||
|
||||
public function testGetBookByDataId ()
|
||||
|
||||
public function testGetBookByDataId ()
|
||||
{
|
||||
$book = Book::getBookByDataId (17);
|
||||
|
||||
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $book->getTitle ());
|
||||
}
|
||||
|
||||
|
||||
public function testGetAllRecentBooks ()
|
||||
{
|
||||
// All recent books
|
||||
global $config;
|
||||
|
||||
|
||||
$config['cops_recentbooks_limit'] = 2;
|
||||
|
||||
|
||||
$entryArray = Book::getAllRecentBooks ();
|
||||
$this->assertCount (2, $entryArray);
|
||||
|
||||
|
||||
$config['cops_recentbooks_limit'] = 50;
|
||||
|
||||
|
||||
$entryArray = Book::getAllRecentBooks ();
|
||||
$this->assertCount (14, $entryArray);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("★★★★☆", $book->getRating ());
|
||||
$this->assertEquals ("Strand Magazine", $book->getPublisher()->name);
|
||||
}
|
||||
|
||||
|
||||
public function testGetMostInterestingDataToSendToKindle ()
|
||||
{
|
||||
// Get Alice (available as MOBI, PDF, EPUB in that order)
|
||||
|
@ -176,11 +176,11 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$data = $book->GetMostInterestingDataToSendToKindle ();
|
||||
$this->assertEquals ("EPUB", $data->format);
|
||||
}
|
||||
|
||||
|
||||
public function testGetDataById ()
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
// Get Alice MOBI=>17, PDF=>19, EPUB=>20
|
||||
$book = Book::getBookById(17);
|
||||
$data = $book->getDataById (17);
|
||||
|
@ -190,7 +190,7 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.epub", $data->getUpdatedFilenameEpub ());
|
||||
$this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.kepub.epub", $data->getUpdatedFilenameKepub ());
|
||||
$this->assertEquals (dirname(__FILE__) . "/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub", $data->getLocalPath ());
|
||||
|
||||
|
||||
$config['cops_use_url_rewriting'] = "1";
|
||||
$config['cops_provide_kepub'] = "1";
|
||||
$_SERVER["HTTP_USER_AGENT"] = "Kobo";
|
||||
|
@ -200,35 +200,35 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$config['cops_use_url_rewriting'] = "0";
|
||||
$this->assertEquals ("fetch.php?data=20&type=epub&id=17", $data->getHtmlLink ());
|
||||
}
|
||||
|
||||
|
||||
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"]);
|
||||
|
@ -244,23 +244,23 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("2 publishers", $array[0]["title"]);
|
||||
$this->assertEquals ("Macmillan and Co. London", $array[1]["title"]);
|
||||
$this->assertEquals ("Macmillan Publishers USA", $array[2]["title"]);
|
||||
|
||||
|
||||
$_GET["query"] = NULL;
|
||||
$_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"]);
|
||||
|
@ -270,9 +270,9 @@ class BookTest extends PHPUnit_Framework_TestCase
|
|||
$_GET["query"] = NULL;
|
||||
$_GET["search"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function tearDown () {
|
||||
Base::clearDb ();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ require_once (dirname(__FILE__) . "/config_test.php");
|
|||
require_once (dirname(__FILE__) . "/../book.php");
|
||||
|
||||
class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
{
|
||||
public function testPageIndex ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -20,10 +20,10 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ($config['cops_title_default'], $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
|
||||
|
@ -32,7 +32,7 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchXXX ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -42,10 +42,10 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
|||
$query = "art";
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$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);
|
||||
|
@ -54,7 +54,7 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public static function tearDownAfterClass () {
|
||||
Base::clearDb ();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once (dirname(__FILE__) . "/config_test.php");
|
|||
require_once (dirname(__FILE__) . "/../book.php");
|
||||
|
||||
class PageTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
{
|
||||
public function testPageIndex ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -18,10 +18,10 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ($config['cops_title_default'], $currentPage->title);
|
||||
$this->assertCount (7, $currentPage->entryArray);
|
||||
$this->assertEquals ("Authors", $currentPage->entryArray [0]->title);
|
||||
|
@ -40,7 +40,7 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("50 most recent books", $currentPage->entryArray [6]->content);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageIndexWithCustomColumn ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -48,125 +48,125 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ("type1");
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertCount (8, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type1", $currentPage->entryArray [5]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [5]->content);
|
||||
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ("type2");
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertCount (8, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type2", $currentPage->entryArray [5]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 3 tags", $currentPage->entryArray [5]->content);
|
||||
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ("type4");
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertCount (8, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type4", $currentPage->entryArray [5]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [5]->content);
|
||||
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ("type1", "type2", "type4");
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertCount (10, $currentPage->entryArray);
|
||||
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ();
|
||||
}
|
||||
|
||||
|
||||
public function testPageAllCustom ()
|
||||
{
|
||||
$page = Base::PAGE_ALL_CUSTOMS;
|
||||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$_GET ["custom"] = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Type4", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("SeriesLike", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = "2";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Type2", $currentPage->title);
|
||||
$this->assertCount (3, $currentPage->entryArray);
|
||||
$this->assertEquals ("tag1", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = "3";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Type1", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("other", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageCustomDetail ()
|
||||
{
|
||||
$page = Base::PAGE_CUSTOM_DETAIL;
|
||||
$query = NULL;
|
||||
$qid = "1";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$_GET ["custom"] = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("SeriesLike", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = "2";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("tag1", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = "3";
|
||||
$qid = "2";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("other", $currentPage->title);
|
||||
$this->assertCount (1, $currentPage->entryArray);
|
||||
$this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["custom"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageAllAuthors ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -174,44 +174,44 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$config['cops_author_split_first_letter'] = "0";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Authors", $currentPage->title);
|
||||
$this->assertCount (5, $currentPage->entryArray);
|
||||
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$config['cops_author_split_first_letter'] = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Authors", $currentPage->title);
|
||||
$this->assertCount (4, $currentPage->entryArray);
|
||||
$this->assertEquals ("C", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageAuthorsFirstLetter ()
|
||||
{
|
||||
$page = Base::PAGE_AUTHORS_FIRST_LETTER;
|
||||
$query = NULL;
|
||||
$qid = "C";
|
||||
$n = "1";
|
||||
|
||||
|
||||
// Author Lewis Carroll
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("1 author starting with C", $currentPage->title);
|
||||
$this->assertCount (1, $currentPage->entryArray);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageAuthorsDetail ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -220,47 +220,47 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$qid = "1";
|
||||
$n = "1";
|
||||
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1";
|
||||
|
||||
$config['cops_max_item_per_page'] = 2;
|
||||
|
||||
|
||||
$config['cops_max_item_per_page'] = 2;
|
||||
|
||||
// First page
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
||||
$this->assertEquals (4, $currentPage->getMaxPage ());
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
$this->assertTrue ($currentPage->IsPaginated ());
|
||||
$this->assertNull ($currentPage->getPrevLink ());
|
||||
|
||||
|
||||
// Last page
|
||||
$config['cops_max_item_per_page'] = 5;
|
||||
$config['cops_max_item_per_page'] = 5;
|
||||
$n = "2";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
||||
$this->assertEquals (2, $currentPage->getMaxPage ());
|
||||
$this->assertCount (3, $currentPage->entryArray);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
$this->assertTrue ($currentPage->IsPaginated ());
|
||||
$this->assertNull ($currentPage->getNextLink ());
|
||||
|
||||
|
||||
// No pagination
|
||||
$config['cops_max_item_per_page'] = -1;
|
||||
|
||||
$config['cops_max_item_per_page'] = -1;
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
||||
$this->assertCount (8, $currentPage->entryArray);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
$this->assertFalse ($currentPage->IsPaginated ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageAllBooks ()
|
||||
{
|
||||
global $config;
|
||||
|
@ -268,19 +268,19 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
$config['cops_titles_split_first_letter'] = 0;
|
||||
|
||||
$config['cops_titles_split_first_letter'] = 0;
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("All books", $currentPage->title);
|
||||
$this->assertCount (14, $currentPage->entryArray);
|
||||
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [1]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
$config['cops_titles_split_first_letter'] = 1;
|
||||
$config['cops_titles_split_first_letter'] = 1;
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
@ -291,48 +291,48 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("C", $currentPage->entryArray [1]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageAllBooksByLetter ()
|
||||
{
|
||||
$page = Base::PAGE_ALL_BOOKS_LETTER;
|
||||
$query = NULL;
|
||||
$qid = "C";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("2 books starting with C", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("The Call of the Wild", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageAllSeries ()
|
||||
{
|
||||
$page = Base::PAGE_ALL_SERIES;
|
||||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Series", $currentPage->title);
|
||||
$this->assertCount (3, $currentPage->entryArray);
|
||||
$this->assertEquals ("D'Artagnan Romances", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageSeriesDetail ()
|
||||
{
|
||||
$page = Base::PAGE_SERIE_DETAIL;
|
||||
$query = NULL;
|
||||
$qid = "1";
|
||||
$n = "1";
|
||||
$n = "1";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Sherlock Holmes", $currentPage->title);
|
||||
$this->assertCount (7, $currentPage->entryArray);
|
||||
$this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [0]->title);
|
||||
|
@ -345,10 +345,10 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Publishers", $currentPage->title);
|
||||
$this->assertCount (5, $currentPage->entryArray);
|
||||
$this->assertEquals ("D. Appleton and Company", $currentPage->entryArray [0]->title);
|
||||
|
@ -361,10 +361,10 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = "6";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Strand Magazine", $currentPage->title);
|
||||
$this->assertCount (8, $currentPage->entryArray);
|
||||
$this->assertEquals ("The Return of Sherlock Holmes", $currentPage->entryArray [0]->title);
|
||||
|
@ -378,26 +378,26 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Tags", $currentPage->title);
|
||||
$this->assertCount (10, $currentPage->entryArray);
|
||||
$this->assertEquals ("Action & Adventure", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageTagDetail ()
|
||||
{
|
||||
$page = Base::PAGE_TAG_DETAIL;
|
||||
$query = NULL;
|
||||
$qid = "1";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Fiction", $currentPage->title);
|
||||
$this->assertCount (14, $currentPage->entryArray);
|
||||
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title);
|
||||
|
@ -410,107 +410,107 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Languages", $currentPage->title);
|
||||
$this->assertCount (1, $currentPage->entryArray);
|
||||
$this->assertEquals ("English", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageLanguageDetail ()
|
||||
{
|
||||
$page = Base::PAGE_LANGUAGE_DETAIL;
|
||||
$query = NULL;
|
||||
$qid = "1";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("English", $currentPage->title);
|
||||
$this->assertCount (14, $currentPage->entryArray);
|
||||
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageRecent ()
|
||||
{
|
||||
$page = Base::PAGE_ALL_RECENT_BOOKS;
|
||||
$query = NULL;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Recent additions", $currentPage->title);
|
||||
$this->assertCount (14, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
// Test facets
|
||||
|
||||
|
||||
$_GET["tag"] = "Historical";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Recent additions", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Twenty Years After", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET["tag"] = "!Romance";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Recent additions", $currentPage->title);
|
||||
$this->assertCount (12, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET["tag"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageBookDetail ()
|
||||
{
|
||||
$page = Base::PAGE_BOOK_DETAIL;
|
||||
$query = NULL;
|
||||
$qid = "2";
|
||||
$n = "1";
|
||||
|
||||
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("The Return of Sherlock Holmes", $currentPage->title);
|
||||
$this->assertCount (0, $currentPage->entryArray);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearch ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$query = "alice";
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
|
||||
|
||||
// Only books returned
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *alice*", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
$this->assertEquals ("Through the Looking Glass (And What Alice Found There)", $currentPage->entryArray [1]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
// Match Lewis Caroll & Scarlet
|
||||
$query = "car";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *car*", $currentPage->title);
|
||||
$this->assertCount (3, $currentPage->entryArray);
|
||||
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title);
|
||||
|
@ -518,102 +518,102 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals ("Through the Looking Glass (And What Alice Found There)", $currentPage->entryArray [2]->title);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchScopeAuthors ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$_GET ["scope"] = "author";
|
||||
|
||||
|
||||
// Match Lewis Carroll
|
||||
$query = "car";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *car* in authors", $currentPage->title);
|
||||
$this->assertCount (1, $currentPage->entryArray);
|
||||
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchScopeSeries ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$_GET ["scope"] = "series";
|
||||
|
||||
|
||||
// Match Holmes
|
||||
$query = "hol";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *hol* in series", $currentPage->title);
|
||||
$this->assertCount (1, $currentPage->entryArray);
|
||||
$this->assertEquals ("Sherlock Holmes", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchScopeBooks ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$_GET ["scope"] = "book";
|
||||
|
||||
|
||||
// Match Holmes
|
||||
$query = "hol";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *hol* in books", $currentPage->title);
|
||||
$this->assertCount (4, $currentPage->entryArray);
|
||||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchScopePublishers ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$_GET ["scope"] = "publisher";
|
||||
|
||||
|
||||
// Match Holmes
|
||||
$query = "millan";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *millan* in publishers", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertEquals ("Macmillan and Co. London", $currentPage->entryArray [0]->title);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
|
||||
|
||||
public function testPageSearchScopeTags ()
|
||||
{
|
||||
$page = Base::PAGE_OPENSEARCH_QUERY;
|
||||
$qid = NULL;
|
||||
$n = "1";
|
||||
$_GET ["scope"] = "tag";
|
||||
|
||||
|
||||
// Match Holmes
|
||||
$query = "fic";
|
||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
|
||||
$this->assertEquals ("Search result for *fic* in tags", $currentPage->title);
|
||||
$this->assertCount (2, $currentPage->entryArray);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
|
||||
|
||||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue