**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*
This commit is contained in:
parent
9d4e358738
commit
9efcd661a0
9 changed files with 296 additions and 28 deletions
|
|
@ -25,19 +25,21 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$currentPage->InitializeContent ();
|
||||
|
||||
$this->assertEquals ($config['cops_title_default'], $currentPage->title);
|
||||
$this->assertCount (6, $currentPage->entryArray);
|
||||
$this->assertCount (7, $currentPage->entryArray);
|
||||
$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);
|
||||
$this->assertEquals ("Tags", $currentPage->entryArray [2]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 10 tags", $currentPage->entryArray [2]->content);
|
||||
$this->assertEquals ("Languages", $currentPage->entryArray [3]->title);
|
||||
$this->assertEquals ("Alphabetical index of the single language", $currentPage->entryArray [3]->content);
|
||||
$this->assertEquals ("All books", $currentPage->entryArray [4]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 14 books", $currentPage->entryArray [4]->content);
|
||||
$this->assertEquals ("Recent additions", $currentPage->entryArray [5]->title);
|
||||
$this->assertEquals ("50 most recent books", $currentPage->entryArray [5]->content);
|
||||
$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);
|
||||
$this->assertFalse ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
|
|
@ -56,34 +58,34 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||
$currentPage->InitializeContent ();
|
||||
|
||||
$this->assertCount (7, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type1", $currentPage->entryArray [4]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [4]->content);
|
||||
$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 (7, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type2", $currentPage->entryArray [4]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 3 tags", $currentPage->entryArray [4]->content);
|
||||
$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 (7, $currentPage->entryArray);
|
||||
$this->assertEquals ("Type4", $currentPage->entryArray [4]->title);
|
||||
$this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [4]->content);
|
||||
$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 (9, $currentPage->entryArray);
|
||||
$this->assertCount (10, $currentPage->entryArray);
|
||||
|
||||
$config['cops_calibre_custom_column'] = array ();
|
||||
}
|
||||
|
|
@ -366,6 +368,45 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertTrue ($currentPage->ContainsBook ());
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
@ -602,6 +643,29 @@ class PageTest extends PHPUnit_Framework_TestCase
|
|||
$_GET ["scope"] = NULL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function testPageSearchScopeTags ()
|
||||
{
|
||||
global $config;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue