1 | <?php |
||
12 | { |
||
13 | public function testPageIndex () |
||
14 | { |
||
15 | global $config; |
||
16 | $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/", |
||
17 | "One book" => dirname(__FILE__) . "/BaseWithOneBook/"); |
||
18 | $page = Base::PAGE_INDEX; |
||
19 | $query = NULL; |
||
20 | $qid = NULL; |
||
21 | $n = "1"; |
||
22 | |||
23 | $currentPage = Page::getPage ($page, $qid, $query, $n); |
||
24 | $currentPage->InitializeContent (); |
||
25 | |||
26 | $this->assertEquals ($config['cops_title_default'], $currentPage->title); |
||
27 | $this->assertCount (2, $currentPage->entryArray); |
||
28 | $this->assertEquals ("Some books", $currentPage->entryArray [0]->title); |
||
29 | $this->assertEquals ("15 books", $currentPage->entryArray [0]->content); |
||
30 | $this->assertEquals (15, $currentPage->entryArray [0]->numberOfElement); |
||
31 | $this->assertEquals ("One book", $currentPage->entryArray [1]->title); |
||
32 | $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); |
||
33 | $this->assertEquals (1, $currentPage->entryArray [1]->numberOfElement); |
||
34 | $this->assertFalse ($currentPage->ContainsBook ()); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @dataProvider providerSearch |
||
39 | */ |
||
40 | public function testPageSearchXXX ($maxItem) |
||
41 | { |
||
42 | global $config; |
||
43 | $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/", |
||
44 | "One book" => dirname(__FILE__) . "/BaseWithOneBook/"); |
||
45 | $page = Base::PAGE_OPENSEARCH_QUERY; |
||
46 | $query = "art"; |
||
47 | $qid = NULL; |
||
48 | $n = "1"; |
||
49 | |||
50 | // Issue 124 |
||
51 | $config['cops_max_item_per_page'] = $maxItem; |
||
52 | $currentPage = Page::getPage ($page, $qid, $query, $n); |
||
53 | $currentPage->InitializeContent (); |
||
54 | |||
55 | |||
56 | $this->assertEquals ("Search result for *art*", $currentPage->title); |
||
57 | $this->assertCount (2, $currentPage->entryArray); |
||
58 | $this->assertEquals ("Some books", $currentPage->entryArray [0]->title); |
||
59 | $this->assertEquals ("11 books", $currentPage->entryArray [0]->content); |
||
60 | $this->assertEquals ("One book", $currentPage->entryArray [1]->title); |
||
61 | $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); |
||
62 | $this->assertFalse ($currentPage->ContainsBook ()); |
||
63 | } |
||
64 | |||
65 | public function providerSearch () |
||
66 | { |
||
67 | return array ( |
||
68 | array (2), |
||
69 | array (-1) |
||
70 | ); |
||
71 | } |
||
72 | |||
73 | public static function tearDownAfterClass () { |
||
74 | Base::clearDb (); |
||
75 | } |
||
76 | |||
77 | } |
||
78 |