cops/test/pageTest.php

690 lines
26 KiB
PHP
Raw Normal View History

2013-10-12 08:56:17 +03: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>
*/
2013-10-12 08:56:17 +03:00
require_once (dirname(__FILE__) . "/config_test.php");
require_once (dirname(__FILE__) . "/../book.php");
class PageTest extends PHPUnit_Framework_TestCase
{
public function testPageIndex ()
{
global $config;
$page = Base::PAGE_INDEX;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$currentPage = Page::getPage ($page, $qid, $query, $n);
$currentPage->InitializeContent ();
$this->assertEquals ($config['cops_title_default'], $currentPage->title);
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$this->assertCount (7, $currentPage->entryArray);
2013-10-12 08:56:17 +03:00
$this->assertEquals ("Authors", $currentPage->entryArray [0]->title);
$this->assertEquals ("Alphabetical index of the 5 authors", $currentPage->entryArray [0]->content);
$this->assertEquals ("Series", $currentPage->entryArray [1]->title);
$this->assertEquals ("Alphabetical index of the 3 series", $currentPage->entryArray [1]->content);
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$this->assertEquals ("Publishers", $currentPage->entryArray [2]->title);
$this->assertEquals ("Alphabetical index of the 5 publishers", $currentPage->entryArray [2]->content);
$this->assertEquals ("Tags", $currentPage->entryArray [3]->title);
$this->assertEquals ("Alphabetical index of the 10 tags", $currentPage->entryArray [3]->content);
$this->assertEquals ("Languages", $currentPage->entryArray [4]->title);
$this->assertEquals ("Alphabetical index of the single language", $currentPage->entryArray [4]->content);
$this->assertEquals ("All books", $currentPage->entryArray [5]->title);
$this->assertEquals ("Alphabetical index of the 14 books", $currentPage->entryArray [5]->content);
$this->assertEquals ("Recent additions", $currentPage->entryArray [6]->title);
$this->assertEquals ("50 most recent books", $currentPage->entryArray [6]->content);
2013-10-12 08:56:17 +03:00
$this->assertFalse ($currentPage->ContainsBook ());
}
public function testPageIndexWithCustomColumn ()
{
global $config;
$page = Base::PAGE_INDEX;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$config['cops_calibre_custom_column'] = array ("type1");
$currentPage = Page::getPage ($page, $qid, $query, $n);
$currentPage->InitializeContent ();
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$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 ();
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$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 ();
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$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 ();
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
$this->assertCount (10, $currentPage->entryArray);
$config['cops_calibre_custom_column'] = array ();
}
2013-10-22 11:24:13 +03:00
public function testPageAllCustom ()
{
global $config;
$page = Base::PAGE_ALL_CUSTOMS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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 ()
{
global $config;
$page = Base::PAGE_CUSTOM_DETAIL;
$query = NULL;
$search = NULL;
$qid = "1";
$n = "1";
$database = NULL;
$_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 ());
2013-10-22 11:24:13 +03:00
$_GET ["custom"] = NULL;
}
2013-10-12 08:56:17 +03:00
public function testPageAllAuthors ()
{
global $config;
$page = Base::PAGE_ALL_AUTHORS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_AUTHORS_FIRST_LETTER;
$query = NULL;
$search = NULL;
$qid = "C";
$n = "1";
$database = NULL;
// 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;
$page = Base::PAGE_AUTHOR_DETAIL;
$query = NULL;
$search = NULL;
$qid = "1";
$n = "1";
$database = NULL;
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1";
$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;
$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;
$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;
$page = Base::PAGE_ALL_BOOKS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$config['cops_titles_split_first_letter'] = 0;
2013-10-12 08:56:17 +03:00
$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;
$currentPage = Page::getPage ($page, $qid, $query, $n);
$currentPage->InitializeContent ();
2013-10-12 08:56:17 +03:00
$this->assertEquals ("All books", $currentPage->title);
$this->assertCount (9, $currentPage->entryArray);
$this->assertEquals ("A", $currentPage->entryArray [0]->title);
$this->assertEquals ("C", $currentPage->entryArray [1]->title);
$this->assertFalse ($currentPage->ContainsBook ());
}
public function testPageAllBooksByLetter ()
{
global $config;
$page = Base::PAGE_ALL_BOOKS_LETTER;
$query = NULL;
$search = NULL;
$qid = "C";
$n = "1";
$database = NULL;
$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 ());
}
2013-10-12 09:19:18 +03:00
public function testPageAllSeries ()
{
global $config;
$page = Base::PAGE_ALL_SERIES;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_SERIE_DETAIL;
$query = NULL;
$search = NULL;
$qid = "1";
$n = "1";
$database = NULL;
$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);
$this->assertTrue ($currentPage->ContainsBook ());
}
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
public function testPageAllPublishers ()
{
global $config;
$page = Base::PAGE_ALL_PUBLISHERS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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);
$this->assertFalse ($currentPage->ContainsBook ());
}
public function testPagePublishersDetail ()
{
global $config;
$page = Base::PAGE_PUBLISHER_DETAIL;
$query = NULL;
$search = NULL;
$qid = "6";
$n = "1";
$database = NULL;
$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);
$this->assertTrue ($currentPage->ContainsBook ());
}
public function testPageAllTags ()
{
global $config;
$page = Base::PAGE_ALL_TAGS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_TAG_DETAIL;
$query = NULL;
$search = NULL;
$qid = "1";
$n = "1";
$database = NULL;
$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);
$this->assertTrue ($currentPage->ContainsBook ());
}
public function testPageAllLanguages ()
{
global $config;
$page = Base::PAGE_ALL_LANGUAGES;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_LANGUAGE_DETAIL;
$query = NULL;
$search = NULL;
$qid = "1";
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_ALL_RECENT_BOOKS;
$query = NULL;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$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 ()
{
global $config;
$page = Base::PAGE_BOOK_DETAIL;
$query = NULL;
$search = NULL;
$qid = "2";
$n = "1";
$database = NULL;
$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 ());
}
2013-10-12 09:19:18 +03:00
2013-10-22 15:38:39 +03:00
public function testPageSearch ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$query = "alice";
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
// 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 ());
2013-10-22 15:39:25 +03:00
// Match Lewis Caroll & Scarlet
2013-10-22 15:38:39 +03:00
$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);
$this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [1]->title);
$this->assertEquals ("Through the Looking Glass (And What Alice Found There)", $currentPage->entryArray [2]->title);
$this->assertTrue ($currentPage->ContainsBook ());
}
2013-10-22 17:51:55 +03:00
public function testPageSearchScopeAuthors ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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 ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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 ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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;
}
**2012-11-22** **Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
2013-11-22 23:08:09 +02:00
public function testPageSearchScopePublishers ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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;
}
2013-10-22 17:51:55 +03:00
public function testPageSearchScopeTags ()
{
global $config;
$page = Base::PAGE_OPENSEARCH_QUERY;
$search = NULL;
$qid = NULL;
$n = "1";
$database = NULL;
$_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;
}
2013-10-12 08:56:17 +03:00
}