**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:
At-Libitum 2013-11-22 22:08:09 +01:00
parent 9d4e358738
commit 9efcd661a0
9 changed files with 296 additions and 28 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
config_local.php
config_local.php
modlog.md

View file

@ -277,7 +277,8 @@ class Entry
Language::ALL_LANGUAGES_ID => 'images/language.png',
CustomColumn::ALL_CUSTOMS_ID => 'images/tag.png',
"cops:books$" => 'images/allbook.png',
"cops:books:letter" => 'images/allbook.png'
"cops:books:letter" => 'images/allbook.png',
"cops:publishers" => 'images/publisher.png'
);
public function getUpdatedTime () {
@ -410,6 +411,10 @@ class Page
return new PageQueryResult ($id, $query, $n);
case Base::PAGE_BOOK_DETAIL :
return new PageBookDetail ($id, $query, $n);
case Base::PAGE_ALL_PUBLISHERS:
return new PageAllPublishers ($id, $query, $n);
case Base::PAGE_PUBLISHER_DETAIL :
return new PagePublisherDetail ($id, $query, $n);
case Base::PAGE_ABOUT :
return new PageAbout ($id, $query, $n);
case Base::PAGE_CUSTOMIZE :
@ -453,6 +458,10 @@ class Page
array_push ($this->entryArray, Author::getCount());
$series = Serie::getCount();
if (!is_null ($series)) array_push ($this->entryArray, $series);
$publisher = Publisher::getCount();
if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
$tags = Tag::getCount();
if (!is_null ($tags)) array_push ($this->entryArray, $tags);
$languages = Language::getCount();
@ -517,7 +526,7 @@ class PageAllAuthors extends Page
global $config;
$this->title = localize("authors.title");
if ($config['cops_author_split_first_letter'] == 1) {
if (getCurrentOption ("author_split_first_letter") == 1) {
$this->entryArray = Author::getAllAuthorsByFirstLetter();
}
else {
@ -548,6 +557,27 @@ class PageAuthorDetail extends Page
}
}
class PageAllPublishers extends Page
{
public function InitializeContent ()
{
$this->title = localize("publisher.title");
$this->entryArray = Publisher::getAllPublishers();
$this->idPage = Publisher::ALL_PUBLISHERS_ID;
}
}
class PagePublisherDetail extends Page
{
public function InitializeContent ()
{
$publisher = Publisher::getPublisherById ($this->idGet);
$this->title = $publisher->name;
list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher ($this->idGet, $this->n);
$this->idPage = $publisher->getEntryId ();
}
}
class PageAllTags extends Page
{
public function InitializeContent ()
@ -680,6 +710,7 @@ class PageQueryResult extends Page
const SCOPE_SERIES = "series";
const SCOPE_AUTHOR = "author";
const SCOPE_BOOK = "book";
const SCOPE_PUBLISHER = "publisher";
public function InitializeContent ()
{
@ -698,6 +729,9 @@ class PageQueryResult extends Page
case self::SCOPE_BOOK :
$this->title = str_format (localize ("search.result.book"), $this->query);
break;
case self::SCOPE_PUBLISHER :
$this->title = str_format (localize ("search.result.publisher"), $this->query);
break;
default:
$this->title = str_format (localize ("search.result"), $this->query);
}
@ -732,6 +766,9 @@ class PageQueryResult extends Page
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
array ($bad, $bad, $bad, $crit), $this->n);
break;
case self::SCOPE_PUBLISHER :
$this->entryArray = Publisher::getAllPublishersByQuery ($this->query);
break;
default:
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
array ($crit, $crit, $crit, $crit), $this->n);
@ -846,6 +883,8 @@ abstract class Base
const PAGE_ALL_LANGUAGES = "17";
const PAGE_LANGUAGE_DETAIL = "18";
const PAGE_CUSTOMIZE = "19";
const PAGE_ALL_PUBLISHERS = "20";
const PAGE_PUBLISHER_DETAIL = "21";
const COMPATIBILITY_XML_ALDIKO = "aldiko";
@ -924,7 +963,6 @@ abstract class Base
// Next modify the query and params
$query .= " limit ?, ?";
array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
}

View file

@ -9,6 +9,7 @@
require_once('base.php');
require_once('serie.php');
require_once('author.php');
require_once('publisher.php');
require_once('tag.php');
require_once('language.php');
require_once("customcolumn.php");
@ -20,6 +21,8 @@ define ('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = book
left outer join books_ratings_link on books_ratings_link.book = books.id
left outer join ratings on books_ratings_link.rating = ratings.id ");
define ('SQL_BOOKS_ALL', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " order by books.sort ");
define ('SQL_BOOKS_BY_PUBLISHER', "select {0} from books_publishers_link, books " . SQL_BOOKS_LEFT_JOIN . "
where books_publishers_link.book = books.id and publisher = ? {1} order by publisher");
define ('SQL_BOOKS_BY_FIRST_LETTER', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
where upper (books.sort) like ? order by books.sort");
define ('SQL_BOOKS_BY_AUTHOR', "select {0} from books_authors_link, books " . SQL_BOOKS_LEFT_JOIN . "
@ -49,6 +52,7 @@ class Book extends Base {
const SQL_BOOKS_LEFT_JOIN = SQL_BOOKS_LEFT_JOIN;
const SQL_BOOKS_ALL = SQL_BOOKS_ALL;
const SQL_BOOKS_BY_PUBLISHER = SQL_BOOKS_BY_PUBLISHER;
const SQL_BOOKS_BY_FIRST_LETTER = SQL_BOOKS_BY_FIRST_LETTER;
const SQL_BOOKS_BY_AUTHOR = SQL_BOOKS_BY_AUTHOR;
const SQL_BOOKS_BY_SERIE = SQL_BOOKS_BY_SERIE;
@ -71,6 +75,7 @@ class Book extends Base {
public $rating;
public $datas = NULL;
public $authors = NULL;
public $publisher = NULL;
public $serie = NULL;
public $tags = NULL;
public $languages = NULL;
@ -119,6 +124,17 @@ class Book extends Base {
array_push ($preferedData, array ("url" => $data->getHtmlLink (), "name" => $format));
}
}
$publisher = $this->getPublisher();
if (is_null ($publisher)) {
$pn = "";
$pu = "";
} else {
$pn = $publisher->name;
$link = new LinkNavigation ($publisher->getUri ());
$pu = $link->hrefXhtml ();
}
$serie = $this->getSerie ();
if (is_null ($serie)) {
$sn = "";
@ -135,6 +151,8 @@ class Book extends Base {
"hasCover" => $this->hasCover,
"preferedData" => $preferedData,
"rating" => $this->getRating (),
"publisherName" => $pn,
"publisherurl" => $pu,
"pubDate" => $this->getPubDate (),
"languagesName" => $this->getLanguages (),
"authorsName" => $this->getAuthorsName (),
@ -215,6 +233,13 @@ class Book extends Base {
return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
}
public function getPublisher () {
if (is_null ($this->publisher)) {
$this->publisher = Publisher::getPublisherByBookId ($this->id);
}
return $this->publisher;
}
public function getSerie () {
if (is_null ($this->serie)) {
$this->serie = Serie::getSerieByBookId ($this->id);
@ -478,6 +503,9 @@ class Book extends Base {
return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n);
}
public static function getBooksByPublisher($publisherId, $n) {
return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n);
}
public static function getBooksBySeries($serieId, $n) {
return self::getEntryArray (self::SQL_BOOKS_BY_SERIE, array ($serieId), $n);
@ -605,7 +633,7 @@ function getJson ($complete = false) {
return $out;
}
$arrayPublisher = Publisher::getAllPublishersByQuery ($query);
$arrayTag = Tag::getAllTagsByQuery ($query, 1, NULL, 5);
@ -618,7 +646,8 @@ function getJson ($complete = false) {
foreach (array ("book" => $arrayBook,
"author" => $arrayAuthor,
"series" => $arraySeries,
"tag" => $arrayTag) as $key => $array) {
"tag" => $arrayTag,
"publisher" => $arrayPublisher) as $key => $array) {
$i = 0;
if (count ($array) == 2 && is_array ($array [0])) {
$total = $array [1];
@ -629,9 +658,10 @@ function getJson ($complete = false) {
if ($total > 0) {
// Comment to help the perl i18n script
// str_format (localize("bookword", count($array))
// str_format (localize("authorword", count($array)
// str_format (localize("seriesword", count($array)
// str_format (localize("tagword", count($array)
// str_format (localize("authorword", count($array))
// str_format (localize("seriesword", count($array))
// str_format (localize("tagword", count($array))
// str_format (localize("publisherword", count($array))
array_push ($out, array ("title" => str_format (localize("{$key}word", $total), $total),
"class" => "tt-header",
"navlink" => "index.php?page={$pagequery}&query={$query}&db={$database}&scope={$key}"));
@ -697,6 +727,7 @@ function getJson ($complete = false) {
"homeAlt" => localize ("home.alternate"),
"cogAlt" => localize ("cog.alternate"),
"permalinkAlt" => localize ("permalink.alternate"),
"publisherName" => localize("publisher.name"),
"pubdateTitle" => localize("pubdate.title"),
"languagesTitle" => localize("language.title"),
"contentTitle" => localize("content.summary"),

View file

@ -10,6 +10,7 @@
require_once ("config.php");
require_once ("base.php");
require_once ("author.php");
require_once ("publisher.php");
require_once ("serie.php");
require_once ("tag.php");
require_once ("language.php");

View file

@ -39,12 +39,21 @@
"paging.previous.alternate":"Previous",
"permalink.alternate":"Permalink",
"pubdate.title":"Publication year",
"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",
"recent.list":"{0} most recent books",
"recent.title":"Recent additions",
"search.alternate":"Search",
"search.result":"Search result for *{0}*",
"search.result.author":"Search result for *{0}* in authors",
"search.result.book":"Search result for *{0}* in books",
"search.result.publisher":"Search result for *{0}* in publishers",
"search.result.series":"Search result for *{0}* in series",
"search.result.tag":"Search result for *{0}* in tags",
"search.sortorder.asc":"Asc",

96
publisher.php Normal file
View file

@ -0,0 +1,96 @@
<?php
/**
* COPS (Calibre OPDS PHP Server) class file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author At Libitum <eljarec@yahoo.com>
*/
require_once('base.php');
class Publisher extends Base {
const ALL_PUBLISHERS_ID = "cops:publishers";
public $id;
public $name;
public function __construct($pid, $pname) {
$this->id = $pid;
$this->name = $pname;
}
public function getUri () {
return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id";
}
public function getEntryId () {
return self::ALL_PUBLISHERS_ID.":".$this->id;
}
public static function getCount() {
$nPublishers = parent::getDb ()->query('select count(*) from publishers')->fetchColumn();
if ($nPublishers == 0) return NULL;
$entry = new Entry (localize("publisher.title"), self::ALL_PUBLISHERS_ID,
str_format (localize("publisher.alphabetical", $nPublishers), $nPublishers), "text",
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_PUBLISHERS)));
return $entry;
}
public static function getPublisherByBookId ($bookId) {
$result = parent::getDb ()->prepare('select publishers.id as id, name
from books_publishers_link, publishers
where publishers.id = publisher and book = ?');
$result->execute (array ($bookId));
if ($post = $result->fetchObject ()) {
return new Publisher ($post->id, $post->name);
}
return NULL;
}
public static function getPublisherById ($publisherId) {
$result = parent::getDb ()->prepare('select id, name
from publishers where id = ?');
$result->execute (array ($publisherId));
if ($post = $result->fetchObject ()) {
return new Publisher ($post->id, $post->name);
}
return NULL;
}
public static function getAllPublishers() {
$result = parent::getDb ()->query('select publishers.id as id, publishers.name as name, count(*) as count
from publishers, books_publishers_link
where publishers.id = publisher
group by publishers.id, publishers.name
order by publishers.name');
$entryArray = array();
while ($post = $result->fetchObject ())
{
$publisher = new Publisher ($post->id, $post->name);
array_push ($entryArray, new Entry ($publisher->name, $publisher->getEntryId (),
str_format (localize("bookword", $post->count), $post->count), "text",
array ( new LinkNavigation ($publisher->getUri ()))));
}
return $entryArray;
}
public static function getAllPublishersByQuery($query) {
$result = parent::getDb ()->prepare('select publishers.id as id, publishers.name as name, count(*) as count
from publishers, books_publishers_link
where publishers.id = publisher and publishers.name like ?
group by publishers.id, publishers.name
order by publishers.name');
$entryArray = array();
$result->execute (array ('%' . $query . '%'));
while ($post = $result->fetchObject ())
{
$publisher = new Publisher ($post->id, $post->name);
array_push ($entryArray, new Entry ($publisher->name, $publisher->getEntryId (),
str_format (localize("bookword", $post->count), $post->count), "text",
array ( new LinkNavigation ($publisher->getUri ()))));
}
return $entryArray;
}
}

Binary file not shown.

View file

@ -9,6 +9,15 @@
require_once (dirname(__FILE__) . "/config_test.php");
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:6 (8 books) Strand Magazine: Arthur Conan Doyle
*/
class BookTest extends PHPUnit_Framework_TestCase
{
public function testGetBookCount ()
@ -74,6 +83,14 @@ class BookTest extends PHPUnit_Framework_TestCase
$this->assertEquals (-1, $totalNumber);
}
public function testGetBooksByPublisher ()
{
// All books from Strand Magazine
list ($entryArray, $totalNumber) = Book::getBooksByPublisher (6, -1);
$this->assertEquals (8, count($entryArray));
$this->assertEquals (-1, $totalNumber);
}
public function testGetBooksByTag ()
{
// All book with the Fiction tag
@ -132,6 +149,7 @@ class BookTest extends PHPUnit_Framework_TestCase
$this->assertEquals ('<p class="description">The Return of Sherlock Holmes is a collection of 13 Sherlock Holmes stories, originally published in 1903-1904, by Arthur Conan Doyle.<br />The book was first published on March 7, 1905 by Georges Newnes, Ltd and in a Colonial edition by Longmans. 30,000 copies were made of the initial print run. The US edition by McClure, Phillips &amp; Co. added another 28,000 to the run.<br />This was the first Holmes collection since 1893, when Holmes had "died" in "The Adventure of the Final Problem". Having published The Hound of the Baskervilles in 19011902 (although setting it before Holmes\' death) Doyle came under intense pressure to revive his famous character.</p>', $book->getComment (false));
$this->assertEquals ("English", $book->getLanguages ());
$this->assertEquals ("", $book->getRating ());
$this->assertEquals ("Strand Magazine", $book->getPublisher()->name);
}
public function testTypeaheadSearch ()
@ -167,6 +185,16 @@ class BookTest extends PHPUnit_Framework_TestCase
$this->assertEquals ("Doyle, Arthur Conan", $array[1]["title"]);
$this->assertEquals ("1 series", $array[2]["title"]);
$this->assertEquals ("D'Artagnan Romances", $array[3]["title"]);
$_GET["query"] = "Macmillan";
$_GET["search"] = "1";
$array = getJson ();
$this->assertCount (3, $array);
$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;

View file

@ -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;