Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.8KB

  1. <?php
  2. /**
  3. * COPS (Calibre OPDS PHP Server) test file
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Sébastien Lucas <sebastien@slucas.fr>
  7. */
  8. require_once (dirname(__FILE__) . "/config_test.php");
  9. require_once (dirname(__FILE__) . "/../book.php");
  10. class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase
  11. {
  12. public function testPageIndex ()
  13. {
  14. global $config;
  15. $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
  16. "One book" => dirname(__FILE__) . "/BaseWithOneBook/");
  17. $page = Base::PAGE_INDEX;
  18. $query = NULL;
  19. $qid = NULL;
  20. $n = "1";
  21. $currentPage = Page::getPage ($page, $qid, $query, $n);
  22. $currentPage->InitializeContent ();
  23. $this->assertEquals ($config['cops_title_default'], $currentPage->title);
  24. $this->assertCount (2, $currentPage->entryArray);
  25. $this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
  26. $this->assertEquals ("15 books", $currentPage->entryArray [0]->content);
  27. $this->assertEquals (15, $currentPage->entryArray [0]->numberOfElement);
  28. $this->assertEquals ("One book", $currentPage->entryArray [1]->title);
  29. $this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
  30. $this->assertEquals (1, $currentPage->entryArray [1]->numberOfElement);
  31. $this->assertFalse ($currentPage->ContainsBook ());
  32. }
  33. /**
  34. * @dataProvider providerSearch
  35. */
  36. public function testPageSearchXXX ($maxItem)
  37. {
  38. global $config;
  39. $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
  40. "One book" => dirname(__FILE__) . "/BaseWithOneBook/");
  41. $page = Base::PAGE_OPENSEARCH_QUERY;
  42. $query = "art";
  43. $qid = NULL;
  44. $n = "1";
  45. // Issue 124
  46. $config['cops_max_item_per_page'] = $maxItem;
  47. $currentPage = Page::getPage ($page, $qid, $query, $n);
  48. $currentPage->InitializeContent ();
  49. $this->assertEquals ("Search result for *art*", $currentPage->title);
  50. $this->assertCount (2, $currentPage->entryArray);
  51. $this->assertEquals ("Some books", $currentPage->entryArray [0]->title);
  52. $this->assertEquals ("11 books", $currentPage->entryArray [0]->content);
  53. $this->assertEquals ("One book", $currentPage->entryArray [1]->title);
  54. $this->assertEquals ("1 book", $currentPage->entryArray [1]->content);
  55. $this->assertFalse ($currentPage->ContainsBook ());
  56. }
  57. public function providerSearch ()
  58. {
  59. return array (
  60. array (2),
  61. array (-1)
  62. );
  63. }
  64. public static function tearDownAfterClass () {
  65. Base::clearDb ();
  66. }
  67. }