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 <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
require_once (dirname(__FILE__) . "/config_test.php"); |
10
|
|
|
|
11
|
|
|
class PageTest extends PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
public function testPageIndex () |
14
|
|
|
{ |
15
|
|
|
global $config; |
16
|
|
|
$page = Base::PAGE_INDEX; |
17
|
|
|
$query = NULL; |
18
|
|
|
$qid = NULL; |
19
|
|
|
$n = "1"; |
20
|
|
|
|
21
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
22
|
|
|
$currentPage->InitializeContent (); |
23
|
|
|
|
24
|
|
|
$this->assertEquals ($config['cops_title_default'], $currentPage->title); |
25
|
|
|
$this->assertCount (8, $currentPage->entryArray); |
26
|
|
|
$this->assertEquals ("Authors", $currentPage->entryArray [0]->title); |
27
|
|
|
$this->assertEquals ("Alphabetical index of the 6 authors", $currentPage->entryArray [0]->content); |
28
|
|
|
$this->assertEquals (6, $currentPage->entryArray [0]->numberOfElement); |
29
|
|
|
$this->assertEquals ("Series", $currentPage->entryArray [1]->title); |
30
|
|
|
$this->assertEquals ("Alphabetical index of the 4 series", $currentPage->entryArray [1]->content); |
31
|
|
|
$this->assertEquals (4, $currentPage->entryArray [1]->numberOfElement); |
32
|
|
|
$this->assertEquals ("Publishers", $currentPage->entryArray [2]->title); |
33
|
|
|
$this->assertEquals ("Alphabetical index of the 6 publishers", $currentPage->entryArray [2]->content); |
34
|
|
|
$this->assertEquals (6, $currentPage->entryArray [2]->numberOfElement); |
35
|
|
|
$this->assertEquals ("Tags", $currentPage->entryArray [3]->title); |
36
|
|
|
$this->assertEquals ("Alphabetical index of the 11 tags", $currentPage->entryArray [3]->content); |
37
|
|
|
$this->assertEquals (11, $currentPage->entryArray [3]->numberOfElement); |
38
|
|
|
$this->assertEquals ("Ratings", $currentPage->entryArray [4]->title); |
39
|
|
|
$this->assertEquals ("3 ratings", $currentPage->entryArray [4]->content); |
40
|
|
|
$this->assertEquals (3, $currentPage->entryArray [4]->numberOfElement); |
41
|
|
|
$this->assertEquals ("Languages", $currentPage->entryArray [5]->title); |
42
|
|
|
$this->assertEquals ("Alphabetical index of the 2 languages", $currentPage->entryArray [5]->content); |
43
|
|
|
$this->assertEquals (2, $currentPage->entryArray [5]->numberOfElement); |
44
|
|
|
$this->assertEquals ("All books", $currentPage->entryArray [6]->title); |
45
|
|
|
$this->assertEquals ("Alphabetical index of the 15 books", $currentPage->entryArray [6]->content); |
46
|
|
|
$this->assertEquals (15, $currentPage->entryArray [6]->numberOfElement); |
47
|
|
|
$this->assertEquals ("Recent additions", $currentPage->entryArray [7]->title); |
48
|
|
|
$this->assertEquals ("50 most recent books", $currentPage->entryArray [7]->content); |
49
|
|
|
$this->assertEquals (50, $currentPage->entryArray [7]->numberOfElement); |
50
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testPageIndexWithIgnored () |
54
|
|
|
{ |
55
|
|
|
global $config; |
56
|
|
|
$page = Base::PAGE_INDEX; |
57
|
|
|
$query = NULL; |
58
|
|
|
$qid = NULL; |
59
|
|
|
$n = "1"; |
60
|
|
|
|
61
|
|
|
$config ['cops_ignored_categories'] = array ("author", "series", "tag", "publisher", "language"); |
62
|
|
|
|
63
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
64
|
|
|
$currentPage->InitializeContent (); |
65
|
|
|
|
66
|
|
|
$this->assertEquals ($config['cops_title_default'], $currentPage->title); |
67
|
|
|
$this->assertCount (3, $currentPage->entryArray); |
68
|
|
|
$this->assertEquals ("Ratings", $currentPage->entryArray [0]->title); |
69
|
|
|
$this->assertEquals ("All books", $currentPage->entryArray [1]->title); |
70
|
|
|
$this->assertEquals ("Alphabetical index of the 15 books", $currentPage->entryArray [1]->content); |
71
|
|
|
$this->assertEquals ("Recent additions", $currentPage->entryArray [2]->title); |
72
|
|
|
$this->assertEquals ("50 most recent books", $currentPage->entryArray [2]->content); |
73
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testPageIndexWithCustomColumn_Type1 () |
77
|
|
|
{ |
78
|
|
|
global $config; |
79
|
|
|
$page = Base::PAGE_INDEX; |
80
|
|
|
$query = NULL; |
81
|
|
|
$qid = NULL; |
82
|
|
|
$n = "1"; |
83
|
|
|
|
84
|
|
|
$config['cops_calibre_custom_column'] = array ("type1"); |
85
|
|
|
|
86
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
87
|
|
|
$currentPage->InitializeContent (); |
88
|
|
|
|
89
|
|
|
$this->assertCount (9, $currentPage->entryArray); |
90
|
|
|
$this->assertEquals ("Type1", $currentPage->entryArray [6]->title); |
91
|
|
|
$this->assertEquals ("Custom column 'Type1'", $currentPage->entryArray [6]->content); |
92
|
|
|
$this->assertEquals (2, $currentPage->entryArray [6]->numberOfElement); |
93
|
|
|
|
94
|
|
|
$config['cops_calibre_custom_column'] = array (); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function testPageIndexWithCustomColumn_Type2 () |
98
|
|
|
{ |
99
|
|
|
global $config; |
100
|
|
|
$page = Base::PAGE_INDEX; |
101
|
|
|
$query = NULL; |
102
|
|
|
$qid = NULL; |
103
|
|
|
$n = "1"; |
104
|
|
|
|
105
|
|
|
$config['cops_calibre_custom_column'] = array ("type2"); |
106
|
|
|
|
107
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
108
|
|
|
$currentPage->InitializeContent (); |
109
|
|
|
|
110
|
|
|
$this->assertCount (9, $currentPage->entryArray); |
111
|
|
|
$this->assertEquals ("Type2", $currentPage->entryArray [6]->title); |
112
|
|
|
$this->assertEquals ("Custom column 'Type2'", $currentPage->entryArray [6]->content); |
113
|
|
|
$this->assertEquals (3, $currentPage->entryArray [6]->numberOfElement); |
114
|
|
|
|
115
|
|
|
$config['cops_calibre_custom_column'] = array (); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function testPageIndexWithCustomColumn_Type4 () |
119
|
|
|
{ |
120
|
|
|
global $config; |
121
|
|
|
$page = Base::PAGE_INDEX; |
122
|
|
|
$query = NULL; |
123
|
|
|
$qid = NULL; |
124
|
|
|
$n = "1"; |
125
|
|
|
|
126
|
|
|
$config['cops_calibre_custom_column'] = array ("type4"); |
127
|
|
|
|
128
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
129
|
|
|
$currentPage->InitializeContent (); |
130
|
|
|
|
131
|
|
|
$this->assertCount (9, $currentPage->entryArray); |
132
|
|
|
$this->assertEquals ("Type4", $currentPage->entryArray [6]->title); |
133
|
|
|
$this->assertEquals ("Alphabetical index of the 2 series", $currentPage->entryArray [6]->content); |
134
|
|
|
$this->assertEquals (2, $currentPage->entryArray [6]->numberOfElement); |
135
|
|
|
|
136
|
|
|
$config['cops_calibre_custom_column'] = array (); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function testPageIndexWithCustomColumn_ManyTypes () |
140
|
|
|
{ |
141
|
|
|
global $config; |
142
|
|
|
$page = Base::PAGE_INDEX; |
143
|
|
|
$query = NULL; |
144
|
|
|
$qid = NULL; |
145
|
|
|
$n = "1"; |
146
|
|
|
|
147
|
|
|
$config['cops_calibre_custom_column'] = array ("type1", "type2", "type4"); |
148
|
|
|
|
149
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
150
|
|
|
$currentPage->InitializeContent (); |
151
|
|
|
|
152
|
|
|
$this->assertCount (11, $currentPage->entryArray); |
153
|
|
|
|
154
|
|
|
$config['cops_calibre_custom_column'] = array (); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function testPageAllCustom_Type4 () |
158
|
|
|
{ |
159
|
|
|
$page = Base::PAGE_ALL_CUSTOMS; |
160
|
|
|
$query = NULL; |
161
|
|
|
$qid = NULL; |
162
|
|
|
$n = "1"; |
163
|
|
|
|
164
|
|
|
$_GET ["custom"] = "1"; |
165
|
|
|
|
166
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
167
|
|
|
$currentPage->InitializeContent (); |
168
|
|
|
|
169
|
|
|
$this->assertEquals ("Type4", $currentPage->title); |
170
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
171
|
|
|
$this->assertEquals ("SeriesLike", $currentPage->entryArray [0]->title); |
172
|
|
|
$this->assertEquals (2, $currentPage->entryArray [0]->numberOfElement); |
173
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
174
|
|
|
|
175
|
|
|
$_GET ["custom"] = NULL; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function testPageAllCustom_Type2 () |
179
|
|
|
{ |
180
|
|
|
$page = Base::PAGE_ALL_CUSTOMS; |
181
|
|
|
$query = NULL; |
182
|
|
|
$qid = NULL; |
183
|
|
|
$n = "1"; |
184
|
|
|
|
185
|
|
|
$_GET ["custom"] = "2"; |
186
|
|
|
|
187
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
188
|
|
|
$currentPage->InitializeContent (); |
189
|
|
|
|
190
|
|
|
$this->assertEquals ("Type2", $currentPage->title); |
191
|
|
|
$this->assertCount (3, $currentPage->entryArray); |
192
|
|
|
$this->assertEquals ("tag1", $currentPage->entryArray [0]->title); |
193
|
|
|
$this->assertEquals (2, $currentPage->entryArray [0]->numberOfElement); |
194
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
195
|
|
|
|
196
|
|
|
$_GET ["custom"] = NULL; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
public function testPageAllCustom_Type1 () |
200
|
|
|
{ |
201
|
|
|
$page = Base::PAGE_ALL_CUSTOMS; |
202
|
|
|
$query = NULL; |
203
|
|
|
$qid = NULL; |
204
|
|
|
$n = "1"; |
205
|
|
|
|
206
|
|
|
$_GET ["custom"] = "3"; |
207
|
|
|
|
208
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
209
|
|
|
$currentPage->InitializeContent (); |
210
|
|
|
|
211
|
|
|
$this->assertEquals ("Type1", $currentPage->title); |
212
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
213
|
|
|
$this->assertEquals ("other", $currentPage->entryArray [0]->title); |
214
|
|
|
$this->assertEquals (1, $currentPage->entryArray [0]->numberOfElement); |
215
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
216
|
|
|
|
217
|
|
|
$_GET ["custom"] = NULL; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function testPageCustomDetail_Type4 () |
221
|
|
|
{ |
222
|
|
|
$page = Base::PAGE_CUSTOM_DETAIL; |
223
|
|
|
$query = NULL; |
224
|
|
|
$qid = "1"; |
225
|
|
|
$n = "1"; |
226
|
|
|
|
227
|
|
|
$_GET ["custom"] = "1"; |
228
|
|
|
|
229
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
230
|
|
|
$currentPage->InitializeContent (); |
231
|
|
|
|
232
|
|
|
$this->assertEquals ("SeriesLike", $currentPage->title); |
233
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
234
|
|
|
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title); |
235
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
236
|
|
|
|
237
|
|
|
$_GET ["custom"] = NULL; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
public function testPageCustomDetail_Type2 () |
241
|
|
|
{ |
242
|
|
|
$page = Base::PAGE_CUSTOM_DETAIL; |
243
|
|
|
$query = NULL; |
244
|
|
|
$qid = "1"; |
245
|
|
|
$n = "1"; |
246
|
|
|
|
247
|
|
|
$_GET ["custom"] = "2"; |
248
|
|
|
|
249
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
250
|
|
|
$currentPage->InitializeContent (); |
251
|
|
|
|
252
|
|
|
$this->assertEquals ("tag1", $currentPage->title); |
253
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
254
|
|
|
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [0]->title); |
255
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
256
|
|
|
|
257
|
|
|
$_GET ["custom"] = NULL; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
public function testPageCustomDetail_Type1 () |
261
|
|
|
{ |
262
|
|
|
$page = Base::PAGE_CUSTOM_DETAIL; |
263
|
|
|
$query = NULL; |
264
|
|
|
$qid = "1"; |
265
|
|
|
$n = "1"; |
266
|
|
|
|
267
|
|
|
$_GET ["custom"] = "3"; |
268
|
|
|
$qid = "2"; |
269
|
|
|
|
270
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
271
|
|
|
$currentPage->InitializeContent (); |
272
|
|
|
|
273
|
|
|
$this->assertEquals ("other", $currentPage->title); |
274
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
275
|
|
|
$this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [0]->title); |
276
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
277
|
|
|
|
278
|
|
|
$_GET ["custom"] = NULL; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
public function testPageAllAuthors_WithFullName () |
282
|
|
|
{ |
283
|
|
|
global $config; |
284
|
|
|
$page = Base::PAGE_ALL_AUTHORS; |
285
|
|
|
$query = NULL; |
286
|
|
|
$qid = NULL; |
287
|
|
|
$n = "1"; |
288
|
|
|
|
289
|
|
|
$config['cops_author_split_first_letter'] = "0"; |
290
|
|
|
|
291
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
292
|
|
|
$currentPage->InitializeContent (); |
293
|
|
|
|
294
|
|
|
$this->assertEquals ("Authors", $currentPage->title); |
295
|
|
|
$this->assertCount (6, $currentPage->entryArray); |
296
|
|
|
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title); |
297
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
298
|
|
|
|
299
|
|
|
$config['cops_author_split_first_letter'] = "1"; |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
public function testPageAllAuthors_SplittedByFirstLetter () |
303
|
|
|
{ |
304
|
|
|
global $config; |
305
|
|
|
$page = Base::PAGE_ALL_AUTHORS; |
306
|
|
|
$query = NULL; |
307
|
|
|
$qid = NULL; |
308
|
|
|
$n = "1"; |
309
|
|
|
|
310
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
311
|
|
|
$currentPage->InitializeContent (); |
312
|
|
|
|
313
|
|
|
$this->assertEquals ("Authors", $currentPage->title); |
314
|
|
|
$this->assertCount (5, $currentPage->entryArray); |
315
|
|
|
$this->assertEquals ("C", $currentPage->entryArray [0]->title); |
316
|
|
|
$this->assertEquals (1, $currentPage->entryArray [0]->numberOfElement); |
317
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
public function testPageAuthorsFirstLetter () |
321
|
|
|
{ |
322
|
|
|
$page = Base::PAGE_AUTHORS_FIRST_LETTER; |
323
|
|
|
$query = NULL; |
324
|
|
|
$qid = "C"; |
325
|
|
|
$n = "1"; |
326
|
|
|
|
327
|
|
|
// Author Lewis Carroll |
328
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
329
|
|
|
$currentPage->InitializeContent (); |
330
|
|
|
|
331
|
|
|
$this->assertEquals ("1 author starting with C", $currentPage->title); |
332
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
333
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
public function testPageAuthorsDetail_FirstPage () |
337
|
|
|
{ |
338
|
|
|
global $config; |
339
|
|
|
$page = Base::PAGE_AUTHOR_DETAIL; |
340
|
|
|
$query = NULL; |
341
|
|
|
$qid = "1"; |
342
|
|
|
$n = "1"; |
343
|
|
|
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1"; |
344
|
|
|
|
345
|
|
|
$config['cops_max_item_per_page'] = 2; |
346
|
|
|
|
347
|
|
|
// First page |
348
|
|
|
|
349
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
350
|
|
|
$currentPage->InitializeContent (); |
351
|
|
|
|
352
|
|
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title); |
353
|
|
|
$this->assertEquals (4, $currentPage->getMaxPage ()); |
354
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
355
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
356
|
|
|
$this->assertTrue ($currentPage->IsPaginated ()); |
357
|
|
|
$this->assertNull ($currentPage->getPrevLink ()); |
358
|
|
|
|
359
|
|
|
$config['cops_max_item_per_page'] = -1; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
public function testPageAuthorsDetail_LastPage () |
363
|
|
|
{ |
364
|
|
|
global $config; |
365
|
|
|
$page = Base::PAGE_AUTHOR_DETAIL; |
366
|
|
|
$query = NULL; |
367
|
|
|
$qid = "1"; |
368
|
|
|
$n = "1"; |
369
|
|
|
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1"; |
370
|
|
|
|
371
|
|
|
// Last page |
372
|
|
|
$config['cops_max_item_per_page'] = 5; |
373
|
|
|
$n = "2"; |
374
|
|
|
|
375
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
376
|
|
|
$currentPage->InitializeContent (); |
377
|
|
|
|
378
|
|
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title); |
379
|
|
|
$this->assertEquals (2, $currentPage->getMaxPage ()); |
380
|
|
|
$this->assertCount (3, $currentPage->entryArray); |
381
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
382
|
|
|
$this->assertTrue ($currentPage->IsPaginated ()); |
383
|
|
|
$this->assertNull ($currentPage->getNextLink ()); |
384
|
|
|
|
385
|
|
|
// No pagination |
386
|
|
|
$config['cops_max_item_per_page'] = -1; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
public function testPageAuthorsDetail_NoPagination () |
390
|
|
|
{ |
391
|
|
|
global $config; |
392
|
|
|
$page = Base::PAGE_AUTHOR_DETAIL; |
393
|
|
|
$query = NULL; |
394
|
|
|
$qid = "1"; |
395
|
|
|
$n = "1"; |
396
|
|
|
$_SERVER['QUERY_STRING'] = "page=" . Base::PAGE_AUTHOR_DETAIL . "&id=1&n=1"; |
397
|
|
|
|
398
|
|
|
// No pagination |
399
|
|
|
$config['cops_max_item_per_page'] = -1; |
400
|
|
|
|
401
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
402
|
|
|
$currentPage->InitializeContent (); |
403
|
|
|
|
404
|
|
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title); |
405
|
|
|
$this->assertCount (8, $currentPage->entryArray); |
406
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
407
|
|
|
$this->assertFalse ($currentPage->IsPaginated ()); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
public function testPageAllBooks_WithFullName () |
411
|
|
|
{ |
412
|
|
|
global $config; |
413
|
|
|
$page = Base::PAGE_ALL_BOOKS; |
414
|
|
|
$query = NULL; |
415
|
|
|
$qid = NULL; |
416
|
|
|
$n = "1"; |
417
|
|
|
|
418
|
|
|
$config['cops_titles_split_first_letter'] = 0; |
419
|
|
|
|
420
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
421
|
|
|
$currentPage->InitializeContent (); |
422
|
|
|
|
423
|
|
|
$this->assertEquals ("All books", $currentPage->title); |
424
|
|
|
$this->assertCount (15, $currentPage->entryArray); |
425
|
|
|
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title); |
426
|
|
|
$this->assertEquals ("Alice's Adventures in Wonderland", $currentPage->entryArray [1]->title); |
427
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
428
|
|
|
|
429
|
|
|
$config['cops_titles_split_first_letter'] = 1; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
public function testPageAllBooks_SplittedByFirstLetter () |
433
|
|
|
{ |
434
|
|
|
global $config; |
435
|
|
|
$page = Base::PAGE_ALL_BOOKS; |
436
|
|
|
$query = NULL; |
437
|
|
|
$qid = NULL; |
438
|
|
|
$n = "1"; |
439
|
|
|
|
440
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
441
|
|
|
$currentPage->InitializeContent (); |
442
|
|
|
|
443
|
|
|
$this->assertEquals ("All books", $currentPage->title); |
444
|
|
|
$this->assertCount (9, $currentPage->entryArray); |
445
|
|
|
$this->assertEquals ("A", $currentPage->entryArray [0]->title); |
446
|
|
|
$this->assertEquals ("C", $currentPage->entryArray [1]->title); |
447
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
public function testPageAllBooksByLetter () |
451
|
|
|
{ |
452
|
|
|
$page = Base::PAGE_ALL_BOOKS_LETTER; |
453
|
|
|
$query = NULL; |
454
|
|
|
$qid = "C"; |
455
|
|
|
$n = "1"; |
456
|
|
|
|
457
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
458
|
|
|
$currentPage->InitializeContent (); |
459
|
|
|
|
460
|
|
|
$this->assertEquals ("3 books starting with C", $currentPage->title); |
461
|
|
|
$this->assertCount (3, $currentPage->entryArray); |
462
|
|
|
$this->assertEquals ("The Call of the Wild", $currentPage->entryArray [0]->title); |
463
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
public function testPageAllSeries () |
467
|
|
|
{ |
468
|
|
|
$page = Base::PAGE_ALL_SERIES; |
469
|
|
|
$query = NULL; |
470
|
|
|
$qid = NULL; |
471
|
|
|
$n = "1"; |
472
|
|
|
|
473
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
474
|
|
|
$currentPage->InitializeContent (); |
475
|
|
|
|
476
|
|
|
$this->assertEquals ("Series", $currentPage->title); |
477
|
|
|
$this->assertCount (4, $currentPage->entryArray); |
478
|
|
|
$this->assertEquals ("D'Artagnan Romances", $currentPage->entryArray [0]->title); |
479
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
public function testPageSeriesDetail () |
483
|
|
|
{ |
484
|
|
|
$page = Base::PAGE_SERIE_DETAIL; |
485
|
|
|
$query = NULL; |
486
|
|
|
$qid = "1"; |
487
|
|
|
$n = "1"; |
488
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
489
|
|
|
$currentPage->InitializeContent (); |
490
|
|
|
|
491
|
|
|
$this->assertEquals ("Sherlock Holmes", $currentPage->title); |
492
|
|
|
$this->assertCount (7, $currentPage->entryArray); |
493
|
|
|
$this->assertEquals ("A Study in Scarlet", $currentPage->entryArray [0]->title); |
494
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
public function testPageAllPublishers () |
498
|
|
|
{ |
499
|
|
|
$page = Base::PAGE_ALL_PUBLISHERS; |
500
|
|
|
$query = NULL; |
501
|
|
|
$qid = NULL; |
502
|
|
|
$n = "1"; |
503
|
|
|
|
504
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
505
|
|
|
$currentPage->InitializeContent (); |
506
|
|
|
|
507
|
|
|
$this->assertEquals ("Publishers", $currentPage->title); |
508
|
|
|
$this->assertCount (6, $currentPage->entryArray); |
509
|
|
|
$this->assertEquals ("D. Appleton and Company", $currentPage->entryArray [0]->title); |
510
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
public function testPagePublishersDetail () |
514
|
|
|
{ |
515
|
|
|
$page = Base::PAGE_PUBLISHER_DETAIL; |
516
|
|
|
$query = NULL; |
517
|
|
|
$qid = "6"; |
518
|
|
|
$n = "1"; |
519
|
|
|
|
520
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
521
|
|
|
$currentPage->InitializeContent (); |
522
|
|
|
|
523
|
|
|
$this->assertEquals ("Strand Magazine", $currentPage->title); |
524
|
|
|
$this->assertCount (8, $currentPage->entryArray); |
525
|
|
|
$this->assertEquals ("The Return of Sherlock Holmes", $currentPage->entryArray [0]->title); |
526
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
public function testPageAllTags () |
530
|
|
|
{ |
531
|
|
|
$page = Base::PAGE_ALL_TAGS; |
532
|
|
|
$query = NULL; |
533
|
|
|
$qid = NULL; |
534
|
|
|
$n = "1"; |
535
|
|
|
|
536
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
537
|
|
|
$currentPage->InitializeContent (); |
538
|
|
|
|
539
|
|
|
$this->assertEquals ("Tags", $currentPage->title); |
540
|
|
|
$this->assertCount (11, $currentPage->entryArray); |
541
|
|
|
$this->assertEquals ("Action & Adventure", $currentPage->entryArray [0]->title); |
542
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
public function testPageTagDetail () |
546
|
|
|
{ |
547
|
|
|
$page = Base::PAGE_TAG_DETAIL; |
548
|
|
|
$query = NULL; |
549
|
|
|
$qid = "1"; |
550
|
|
|
$n = "1"; |
551
|
|
|
|
552
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
553
|
|
|
$currentPage->InitializeContent (); |
554
|
|
|
|
555
|
|
|
$this->assertEquals ("Fiction", $currentPage->title); |
556
|
|
|
$this->assertCount (14, $currentPage->entryArray); |
557
|
|
|
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title); |
558
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
public function testPageAllLanguages () |
562
|
|
|
{ |
563
|
|
|
$page = Base::PAGE_ALL_LANGUAGES; |
564
|
|
|
$query = NULL; |
565
|
|
|
$qid = NULL; |
566
|
|
|
$n = "1"; |
567
|
|
|
|
568
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
569
|
|
|
$currentPage->InitializeContent (); |
570
|
|
|
|
571
|
|
|
$this->assertEquals ("Languages", $currentPage->title); |
572
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
573
|
|
|
$this->assertEquals ("English", $currentPage->entryArray [0]->title); |
574
|
|
|
$this->assertEquals ("French", $currentPage->entryArray [1]->title); |
575
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
public function testPageLanguageDetail () |
579
|
|
|
{ |
580
|
|
|
$page = Base::PAGE_LANGUAGE_DETAIL; |
581
|
|
|
$query = NULL; |
582
|
|
|
$qid = "1"; |
583
|
|
|
$n = "1"; |
584
|
|
|
|
585
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
586
|
|
|
$currentPage->InitializeContent (); |
587
|
|
|
|
588
|
|
|
$this->assertEquals ("English", $currentPage->title); |
589
|
|
|
$this->assertCount (14, $currentPage->entryArray); |
590
|
|
|
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title); |
591
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
public function testPageAllRatings () |
595
|
|
|
{ |
596
|
|
|
$page = Base::PAGE_ALL_RATINGS; |
597
|
|
|
$query = NULL; |
598
|
|
|
$qid = NULL; |
599
|
|
|
$n = "1"; |
600
|
|
|
|
601
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
602
|
|
|
$currentPage->InitializeContent (); |
603
|
|
|
|
604
|
|
|
$this->assertEquals ("Ratings", $currentPage->title); |
605
|
|
|
$this->assertCount (3, $currentPage->entryArray); |
606
|
|
|
$this->assertEquals ("2 stars", $currentPage->entryArray [0]->title); |
607
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
public function testPageRatingDetail () |
611
|
|
|
{ |
612
|
|
|
$page = Base::PAGE_RATING_DETAIL; |
613
|
|
|
$query = NULL; |
614
|
|
|
$qid = "1"; |
615
|
|
|
$n = "1"; |
616
|
|
|
|
617
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
618
|
|
|
$currentPage->InitializeContent (); |
619
|
|
|
|
620
|
|
|
$this->assertEquals ("5 stars", $currentPage->title); |
621
|
|
|
$this->assertCount (4, $currentPage->entryArray); |
622
|
|
|
$this->assertEquals ("The Adventures of Sherlock Holmes", $currentPage->entryArray [0]->title); |
623
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
624
|
|
|
} |
625
|
|
|
|
626
|
|
|
public function testPageRecent () |
627
|
|
|
{ |
628
|
|
|
$page = Base::PAGE_ALL_RECENT_BOOKS; |
629
|
|
|
$query = NULL; |
630
|
|
|
$qid = NULL; |
631
|
|
|
$n = "1"; |
632
|
|
|
|
633
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
634
|
|
|
$currentPage->InitializeContent (); |
635
|
|
|
|
636
|
|
|
$this->assertEquals ("Recent additions", $currentPage->title); |
637
|
|
|
$this->assertCount (15, $currentPage->entryArray); |
638
|
|
|
$this->assertEquals ("La curée", $currentPage->entryArray [0]->title); |
639
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
public function testPageRecent_WithFacets_IncludedTag () |
643
|
|
|
{ |
644
|
|
|
$page = Base::PAGE_ALL_RECENT_BOOKS; |
645
|
|
|
$query = NULL; |
646
|
|
|
$qid = NULL; |
647
|
|
|
$n = "1"; |
648
|
|
|
|
649
|
|
|
$_GET["tag"] = "Historical"; |
650
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
651
|
|
|
$currentPage->InitializeContent (); |
652
|
|
|
|
653
|
|
|
$this->assertEquals ("Recent additions", $currentPage->title); |
654
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
655
|
|
|
$this->assertEquals ("Twenty Years After", $currentPage->entryArray [0]->title); |
656
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
657
|
|
|
|
658
|
|
|
$_GET["tag"] = NULL; |
659
|
|
|
} |
660
|
|
|
|
661
|
|
|
public function testPageRecent_WithFacets_ExcludedTag () |
662
|
|
|
{ |
663
|
|
|
$page = Base::PAGE_ALL_RECENT_BOOKS; |
664
|
|
|
$query = NULL; |
665
|
|
|
$qid = NULL; |
666
|
|
|
$n = "1"; |
667
|
|
|
|
668
|
|
|
$_GET["tag"] = "!Romance"; |
669
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
670
|
|
|
$currentPage->InitializeContent (); |
671
|
|
|
|
672
|
|
|
$this->assertEquals ("Recent additions", $currentPage->title); |
673
|
|
|
$this->assertCount (13, $currentPage->entryArray); |
674
|
|
|
$this->assertEquals ("La curée", $currentPage->entryArray [0]->title); |
675
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
676
|
|
|
|
677
|
|
|
$_GET["tag"] = NULL; |
678
|
|
|
} |
679
|
|
|
|
680
|
|
|
public function testPageBookDetail () |
681
|
|
|
{ |
682
|
|
|
$page = Base::PAGE_BOOK_DETAIL; |
683
|
|
|
$query = NULL; |
684
|
|
|
$qid = "2"; |
685
|
|
|
$n = "1"; |
686
|
|
|
|
687
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
688
|
|
|
$currentPage->InitializeContent (); |
689
|
|
|
|
690
|
|
|
$this->assertEquals ("The Return of Sherlock Holmes", $currentPage->title); |
691
|
|
|
$this->assertCount (0, $currentPage->entryArray); |
692
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
public function testPageSearch_WithOnlyBooksReturned () |
696
|
|
|
{ |
697
|
|
|
global $config; |
698
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
699
|
|
|
$query = "alice"; |
700
|
|
|
$qid = NULL; |
701
|
|
|
$n = "1"; |
702
|
|
|
|
703
|
|
|
// Only books returned |
704
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
705
|
|
|
$currentPage->InitializeContent (); |
706
|
|
|
|
707
|
|
|
$this->assertEquals ("Search result for *alice*", $currentPage->title); |
708
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
709
|
|
|
$this->assertEquals ("Search result for *alice* in books", $currentPage->entryArray [0]->title); |
710
|
|
|
$this->assertEquals ("2 books", $currentPage->entryArray [0]->content); |
711
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
public function testPageSearch_WithAuthorsIgnored () |
715
|
|
|
{ |
716
|
|
|
global $config; |
717
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
718
|
|
|
// Match Lewis Caroll & Scarlet |
719
|
|
|
$query = "car"; |
720
|
|
|
$qid = NULL; |
721
|
|
|
$n = "1"; |
722
|
|
|
|
723
|
|
|
$config ['cops_ignored_categories'] = array ("author"); |
724
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
725
|
|
|
$currentPage->InitializeContent (); |
726
|
|
|
|
727
|
|
|
$this->assertEquals ("Search result for *car*", $currentPage->title); |
728
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
729
|
|
|
$this->assertEquals ("Search result for *car* in books", $currentPage->entryArray [0]->title); |
730
|
|
|
$this->assertEquals ("1 book", $currentPage->entryArray [0]->content); |
731
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
732
|
|
|
|
733
|
|
|
$config ['cops_ignored_categories'] = array (); |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
public function testPageSearch_WithTwoCategories () |
737
|
|
|
{ |
738
|
|
|
global $config; |
739
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
740
|
|
|
// Match Lewis Caroll & Scarlet |
741
|
|
|
$query = "car"; |
742
|
|
|
$qid = NULL; |
743
|
|
|
$n = "1"; |
744
|
|
|
|
745
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
746
|
|
|
$currentPage->InitializeContent (); |
747
|
|
|
|
748
|
|
|
$this->assertEquals ("Search result for *car*", $currentPage->title); |
749
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
750
|
|
|
$this->assertEquals ("Search result for *car* in books", $currentPage->entryArray [0]->title); |
751
|
|
|
$this->assertEquals ("1 book", $currentPage->entryArray [0]->content); |
752
|
|
|
$this->assertEquals ("Search result for *car* in authors", $currentPage->entryArray [1]->title); |
753
|
|
|
$this->assertEquals ("1 author", $currentPage->entryArray [1]->content); |
754
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
755
|
|
|
} |
756
|
|
|
|
757
|
|
|
/** |
758
|
|
|
* @dataProvider providerAccentuatedCharacters |
759
|
|
|
*/ |
760
|
|
|
public function testPageSearch_WithAccentuatedCharacters ($query, $count, $content) |
761
|
|
|
{ |
762
|
|
|
global $config; |
763
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
764
|
|
|
$qid = NULL; |
765
|
|
|
$n = "1"; |
766
|
|
|
|
767
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
768
|
|
|
$currentPage->InitializeContent (); |
769
|
|
|
|
770
|
|
|
$this->assertEquals ("Search result for *$query*", $currentPage->title); |
771
|
|
|
$this->assertCount ($count, $currentPage->entryArray); |
772
|
|
|
if ($count > 0) { |
773
|
|
|
$this->assertEquals ($content, $currentPage->entryArray [0]->content); |
774
|
|
|
} |
775
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
public function providerAccentuatedCharacters () |
779
|
|
|
{ |
780
|
|
|
return array ( |
781
|
|
|
array ("curée", 1, "1 book"), |
782
|
|
|
array ("Émile zola", 1, "1 author"), |
783
|
|
|
array ("émile zola", 0, NULL), // With standard search upper does not work with diacritics |
784
|
|
|
array ("Littérature", 1, "1 tag"), |
785
|
|
|
array ("Eugène Fasquelle", 1, "1 publisher") |
786
|
|
|
); |
787
|
|
|
} |
788
|
|
|
|
789
|
|
|
/** |
790
|
|
|
* @dataProvider providerNormalizedSearch |
791
|
|
|
*/ |
792
|
|
|
public function testPageSearch_WithNormalizedSearch_Book ($query, $count, $content) |
793
|
|
|
{ |
794
|
|
|
global $config; |
795
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
796
|
|
|
$qid = NULL; |
797
|
|
|
$n = "1"; |
798
|
|
|
$config ['cops_normalized_search'] = "1"; |
799
|
|
|
Base::clearDb (); |
800
|
|
|
if (!useNormAndUp ()) { |
801
|
|
|
$this->markTestIncomplete(); |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
805
|
|
|
$currentPage->InitializeContent (); |
806
|
|
|
|
807
|
|
|
$this->assertEquals ("Search result for *$query*", $currentPage->title); |
808
|
|
|
$this->assertCount ($count, $currentPage->entryArray); |
809
|
|
|
if ($count > 0) { |
810
|
|
|
$this->assertEquals ($content, $currentPage->entryArray [0]->content); |
811
|
|
|
} |
812
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
813
|
|
|
|
814
|
|
|
$config ['cops_normalized_search'] = "0"; |
815
|
|
|
Base::clearDb (); |
816
|
|
|
} |
817
|
|
|
|
818
|
|
|
public function providerNormalizedSearch () |
819
|
|
|
{ |
820
|
|
|
return array ( |
821
|
|
|
array ("curee", 1, "1 book"), |
822
|
|
|
array ("emile zola", 1, "1 author"), |
823
|
|
|
array ("émile zola", 1, "1 author"), |
824
|
|
|
array ("Litterature", 1, "1 tag"), |
825
|
|
|
array ("Litterâture", 1, "1 tag"), |
826
|
|
|
array ("Serie des Rougon", 1, "1 series"), |
827
|
|
|
array ("Eugene Fasquelle", 1, "1 publisher") |
828
|
|
|
); |
829
|
|
|
} |
830
|
|
|
|
831
|
|
|
public function testAuthorSearch_ByName () |
832
|
|
|
{ |
833
|
|
|
global $config; |
834
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
835
|
|
|
$query = "Lewis Carroll"; |
836
|
|
|
$_GET ["scope"] = "author"; |
837
|
|
|
$qid = NULL; |
838
|
|
|
$n = "1"; |
839
|
|
|
|
840
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
841
|
|
|
$currentPage->InitializeContent (); |
842
|
|
|
|
843
|
|
|
$this->assertEquals ("Search result for *Lewis Carroll* in authors", $currentPage->title); |
844
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
845
|
|
|
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title); |
846
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
847
|
|
|
} |
848
|
|
|
|
849
|
|
|
public function testAuthorSearch_BySort () |
850
|
|
|
{ |
851
|
|
|
global $config; |
852
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
853
|
|
|
$query = "Carroll, Lewis"; |
854
|
|
|
$_GET ["scope"] = "author"; |
855
|
|
|
$qid = NULL; |
856
|
|
|
$n = "1"; |
857
|
|
|
|
858
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
859
|
|
|
$currentPage->InitializeContent (); |
860
|
|
|
|
861
|
|
|
$this->assertEquals ("Search result for *Carroll, Lewis* in authors", $currentPage->title); |
862
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
863
|
|
|
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title); |
864
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
public function testPageSearchScopeAuthors () |
868
|
|
|
{ |
869
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
870
|
|
|
$qid = NULL; |
871
|
|
|
$n = "1"; |
872
|
|
|
$_GET ["scope"] = "author"; |
873
|
|
|
|
874
|
|
|
// Match Lewis Carroll |
875
|
|
|
$query = "car"; |
876
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
877
|
|
|
$currentPage->InitializeContent (); |
878
|
|
|
|
879
|
|
|
$this->assertEquals ("Search result for *car* in authors", $currentPage->title); |
880
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
881
|
|
|
$this->assertEquals ("Carroll, Lewis", $currentPage->entryArray [0]->title); |
882
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
883
|
|
|
|
884
|
|
|
$_GET ["scope"] = NULL; |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
public function testPageSearchScopeSeries () |
888
|
|
|
{ |
889
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
890
|
|
|
$qid = NULL; |
891
|
|
|
$n = "1"; |
892
|
|
|
$_GET ["scope"] = "series"; |
893
|
|
|
|
894
|
|
|
// Match Holmes |
895
|
|
|
$query = "hol"; |
896
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
897
|
|
|
$currentPage->InitializeContent (); |
898
|
|
|
|
899
|
|
|
$this->assertEquals ("Search result for *hol* in series", $currentPage->title); |
900
|
|
|
$this->assertCount (1, $currentPage->entryArray); |
901
|
|
|
$this->assertEquals ("Sherlock Holmes", $currentPage->entryArray [0]->title); |
902
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
903
|
|
|
|
904
|
|
|
$_GET ["scope"] = NULL; |
905
|
|
|
} |
906
|
|
|
|
907
|
|
|
public function testPageSearchScopeBooks () |
908
|
|
|
{ |
909
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
910
|
|
|
$qid = NULL; |
911
|
|
|
$n = "1"; |
912
|
|
|
$_GET ["scope"] = "book"; |
913
|
|
|
|
914
|
|
|
// Match Holmes |
915
|
|
|
$query = "hol"; |
916
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
917
|
|
|
$currentPage->InitializeContent (); |
918
|
|
|
|
919
|
|
|
$this->assertEquals ("Search result for *hol* in books", $currentPage->title); |
920
|
|
|
$this->assertCount (4, $currentPage->entryArray); |
921
|
|
|
$this->assertTrue ($currentPage->ContainsBook ()); |
922
|
|
|
|
923
|
|
|
$_GET ["scope"] = NULL; |
924
|
|
|
} |
925
|
|
|
|
926
|
|
|
public function testPageSearchScopePublishers () |
927
|
|
|
{ |
928
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
929
|
|
|
$qid = NULL; |
930
|
|
|
$n = "1"; |
931
|
|
|
$_GET ["scope"] = "publisher"; |
932
|
|
|
|
933
|
|
|
// Match Holmes |
934
|
|
|
$query = "millan"; |
935
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
936
|
|
|
$currentPage->InitializeContent (); |
937
|
|
|
|
938
|
|
|
$this->assertEquals ("Search result for *millan* in publishers", $currentPage->title); |
939
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
940
|
|
|
$this->assertEquals ("Macmillan and Co. London", $currentPage->entryArray [0]->title); |
941
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
942
|
|
|
|
943
|
|
|
$_GET ["scope"] = NULL; |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
public function testPageSearchScopeTags () |
947
|
|
|
{ |
948
|
|
|
$page = Base::PAGE_OPENSEARCH_QUERY; |
949
|
|
|
$qid = NULL; |
950
|
|
|
$n = "1"; |
951
|
|
|
$_GET ["scope"] = "tag"; |
952
|
|
|
|
953
|
|
|
// Match Holmes |
954
|
|
|
$query = "fic"; |
955
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n); |
956
|
|
|
$currentPage->InitializeContent (); |
957
|
|
|
|
958
|
|
|
$this->assertEquals ("Search result for *fic* in tags", $currentPage->title); |
959
|
|
|
$this->assertCount (2, $currentPage->entryArray); |
960
|
|
|
$this->assertFalse ($currentPage->ContainsBook ()); |
961
|
|
|
|
962
|
|
|
$_GET ["scope"] = NULL; |
963
|
|
|
} |
964
|
|
|
} |