Add new test on GetBookByAuthor, also test pagination. re #96

This commit is contained in:
Sébastien Lucas 2013-10-03 18:27:36 +02:00
parent 748913ac83
commit 934c8012ab

View file

@ -39,5 +39,25 @@ class StackTest extends PHPUnit_Framework_TestCase
$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);
}
}