Remove trailing spaces
This commit is contained in:
parent
9f5f00e114
commit
0f09ef5f8c
21 changed files with 478 additions and 478 deletions
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue