Completed
Push — master ( df592e...2bd024 )
by Sébastien
02:12
created

testGetMostInterestingDataToSendToKindle_WithPdf()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
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
require_once (dirname(__FILE__) . "/../book.php");
11
require_once (dirname(__FILE__) . "/../JSON_renderer.php");
12
13
/*
14
Publishers:
15
id:2 (2 books)   Macmillan and Co. London:   Lewis Caroll
16
id:3 (2 books)   D. Appleton and Company     Alexander Dumas
17
id:4 (1 book)    Macmillan Publishers USA:   Jack London
18
id:5 (1 book)    Pierson's Magazine:         H. G. Wells
19
id:6 (8 books)   Strand Magazine:            Arthur Conan Doyle
20
*/
21
22
define ("TEST_THUMBNAIL", dirname(__FILE__) . "/thumbnail.jpg");
23
define ("COVER_WIDTH", 400);
24
define ("COVER_HEIGHT", 600);
25
26
class BookTest extends PHPUnit_Framework_TestCase
27
{
28
    public static function setUpBeforeClass()
29
    {
30
        $book = Book::getBookById(2);
31
        if (!is_dir ($book->path)) {
32
            mkdir ($book->path, 0777, true);
33
        }
34
        $im = imagecreatetruecolor(COVER_WIDTH, COVER_HEIGHT);
35
        $text_color = imagecolorallocate($im, 255, 0, 0);
36
        imagestring($im, 1, 5, 5,  'Book cover', $text_color);
37
        imagejpeg ($im, $book->path . "/cover.jpg", 80);
38
    }
39
40
    public static function tearDownAfterClass()
41
    {
42
        $book = Book::getBookById(2);
43
        if (!file_exists ($book->path . "/cover.jpg")) {
44
            return;
45
        }
46
        unlink ($book->path . "/cover.jpg");
47
        rmdir ($book->path);
48
        rmdir (dirname ($book->path));
49
    }
50
51
    public function testGetBookCount ()
52
    {
53
        $this->assertEquals (15, Book::getBookCount ());
54
    }
55
56
    public function testGetCount ()
57
    {
58
        $entryArray = Book::getCount ();
59
        $this->assertEquals (2, count($entryArray));
60
61
        $entryAllBooks = $entryArray [0];
62
        $this->assertEquals ("Alphabetical index of the 15 books", $entryAllBooks->content);
63
64
        $entryRecentBooks = $entryArray [1];
65
        $this->assertEquals ("50 most recent books", $entryRecentBooks->content);
66
67
    }
68
69
    public function testGetCountRecent ()
70
    {
71
        global $config;
72
        $config['cops_recentbooks_limit'] = 0;
73
        $entryArray = Book::getCount ();
74
75
        $this->assertEquals (1, count($entryArray));
76
77
        $config['cops_recentbooks_limit'] = 2;
78
        $entryArray = Book::getCount ();
79
80
        $entryRecentBooks = $entryArray [1];
81
        $this->assertEquals ("2 most recent books", $entryRecentBooks->content);
82
83
        $config['cops_recentbooks_limit'] = 50;
84
    }
85
86
    public function testGetBooksByAuthor ()
87
    {
88
        // All book by Arthur Conan Doyle
89
        global $config;
90
91
        $config['cops_max_item_per_page'] = 5;
92
        list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, 1);
93
        $this->assertEquals (5, count($entryArray));
94
        $this->assertEquals (8, $totalNumber);
95
96
        list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, 2);
97
        $this->assertEquals (3, count($entryArray));
98
        $this->assertEquals (8, $totalNumber);
99
100
        $config['cops_max_item_per_page'] = -1;
101
        list ($entryArray, $totalNumber) = Book::getBooksByAuthor (1, -1);
102
        $this->assertEquals (8, count($entryArray));
103
        $this->assertEquals (-1, $totalNumber);
104
    }
105
106
    public function testGetBooksBySeries ()
107
    {
108
        // All book from the Sherlock Holmes series
109
        list ($entryArray, $totalNumber) = Book::getBooksBySeries (1, -1);
110
        $this->assertEquals (7, count($entryArray));
111
        $this->assertEquals (-1, $totalNumber);
112
    }
113
114
    public function testGetBooksByPublisher ()
115
    {
116
        // All books from Strand Magazine
117
        list ($entryArray, $totalNumber) = Book::getBooksByPublisher (6, -1);
118
        $this->assertEquals (8, count($entryArray));
119
        $this->assertEquals (-1, $totalNumber);
120
    }
121
122
    public function testGetBooksByTag ()
123
    {
124
        // All book with the Fiction tag
125
        list ($entryArray, $totalNumber) = Book::getBooksByTag (1, -1);
126
        $this->assertEquals (14, count($entryArray));
127
        $this->assertEquals (-1, $totalNumber);
128
    }
129
130
    public function testGetBooksByLanguage ()
131
    {
132
        // All english book (= all books)
133
        list ($entryArray, $totalNumber) = Book::getBooksByLanguage (1, -1);
134
        $this->assertEquals (14, count($entryArray));
135
        $this->assertEquals (-1, $totalNumber);
136
    }
137
138
    public function testGetAllBooks ()
139
    {
140
        // All books by first letter
141
        $entryArray = Book::getAllBooks ();
142
        $this->assertCount (9, $entryArray);
143
    }
144
145
    public function testGetBooksByStartingLetter ()
146
    {
147
        // All books by first letter
148
        list ($entryArray, $totalNumber) = Book::getBooksByStartingLetter ("T", -1);
149
        $this->assertEquals (-1, $totalNumber);
150
        $this->assertCount (3, $entryArray);
151
    }
152
153
    public function testGetBookByDataId ()
154
    {
155
        $book = Book::getBookByDataId (17);
156
157
        $this->assertEquals ("Alice's Adventures in Wonderland", $book->getTitle ());
158
    }
159
160
    public function testGetAllRecentBooks ()
161
    {
162
        // All recent books
163
        global $config;
164
165
        $config['cops_recentbooks_limit'] = 2;
166
167
        $entryArray = Book::getAllRecentBooks ();
168
        $this->assertCount (2, $entryArray);
169
170
        $config['cops_recentbooks_limit'] = 50;
171
172
        $entryArray = Book::getAllRecentBooks ();
173
        $this->assertCount (15, $entryArray);
174
    }
175
176
    /**
177
     * @dataProvider providerPublicationDate
178
     */
179
    public function testGetPubDate ($pubdate, $expectedYear)
180
    {
181
        $book = Book::getBookById(2);
182
        $book->pubdate = $pubdate;
183
        $this->assertEquals($expectedYear, $book->getPubDate());
184
    }
185
186
    public function providerPublicationDate() {
187
        return array(
188
            array('2010-10-05 22:00:00+00:00', '2010'),
189
            array('1982-11-15 13:05:29.908657+00:00', '1982'),
190
            array('1562-10-05 00:00:00+00:00', '1562'),
191
            array('0100-12-31 23:00:00+00:00', ''),
192
            array('', ''),
193
            array(NULL, '')
194
            );
195
    }
196
197
    public function testGetBookById ()
198
    {
199
        // also check most of book's class methods
200
        $book = Book::getBookById(2);
201
202
        $linkArray = $book->getLinkArray ();
203
        $this->assertCount (5, $linkArray);
204
205
        $this->assertEquals ("The Return of Sherlock Holmes", $book->getTitle ());
206
        $this->assertEquals ("urn:uuid:87ddbdeb-1e27-4d06-b79b-4b2a3bfc6a5f", $book->getEntryId ());
207
        $this->assertEquals ("index.php?page=13&id=2", $book->getDetailUrl ());
208
        $this->assertEquals ("Arthur Conan Doyle", $book->getAuthorsName ());
209
        $this->assertEquals ("Fiction, Mystery & Detective, Short Stories", $book->getTagsName ());
210
        $this->assertEquals ('<p class="description">The Return of Sherlock Holmes is a collection of 13 Sherlock Holmes stories, originally published in 1903-1904, by Arthur Conan Doyle.<br />The book was first published on March 7, 1905 by Georges Newnes, Ltd and in a Colonial edition by Longmans. 30,000 copies were made of the initial print run. The US edition by McClure, Phillips &amp; Co. added another 28,000 to the run.<br />This was the first Holmes collection since 1893, when Holmes had "died" in "The Adventure of the Final Problem". Having published The Hound of the Baskervilles in 1901–1902 (although setting it before Holmes\' death) Doyle came under intense pressure to revive his famous character.</p>', $book->getComment (false));
211
        $this->assertEquals ("English", $book->getLanguages ());
212
        $this->assertEquals ("Strand Magazine", $book->getPublisher()->name);
213
    }
214
215
    public function testGetBookById_NotFound ()
216
    {
217
        $book = Book::getBookById(666);
218
219
        $this->assertNull ($book);
220
    }
221
222
    public function testGetRating_FiveStars ()
223
    {
224
        $book = Book::getBookById(2);
225
226
        $this->assertEquals ("&#9733;&#9733;&#9733;&#9733;&#9733;", $book->getRating ());
227
    }
228
229
    public function testGetRating_FourStars ()
230
    {
231
        $book = Book::getBookById(2);
232
        $book->rating = 8;
233
234
        // 4 filled stars and one empty
235
        $this->assertEquals ("&#9733;&#9733;&#9733;&#9733;&#9734;", $book->getRating ());
236
    }
237
238
    public function testGetRating_NoStars_Zero ()
239
    {
240
        $book = Book::getBookById(2);
241
        $book->rating = 0;
242
243
        $this->assertEquals ("", $book->getRating ());
244
    }
245
246
    public function testGetRating_NoStars_Null ()
247
    {
248
        $book = Book::getBookById(2);
249
        $book->rating = NULL;
250
251
        $this->assertEquals ("", $book->getRating ());
252
    }
253
254
    public function testBookGetLinkArrayWithUrlRewriting ()
255
    {
256
        global $config;
257
258
        $book = Book::getBookById(2);
259
        $config['cops_use_url_rewriting'] = "1";
260
261
        $linkArray = $book->getLinkArray ();
262
        foreach ($linkArray as $link) {
263
            if ($link->rel == Link::OPDS_ACQUISITION_TYPE && $link->title == "EPUB" ) {
264
                $this->assertEquals ("download/1/The%20Return%20of%20Sherlock%20Holmes%20-%20Arthur%20Conan%20Doyle.epub", $link->href);
265
                return;
266
            }
267
        }
268
        $this->fail ();
269
    }
270
271
    public function testBookGetLinkArrayWithoutUrlRewriting ()
272
    {
273
        global $config;
274
275
        $book = Book::getBookById(2);
276
        $config['cops_use_url_rewriting'] = "0";
277
278
        $linkArray = $book->getLinkArray ();
279
        foreach ($linkArray as $link) {
280
            if ($link->rel == Link::OPDS_ACQUISITION_TYPE && $link->title == "EPUB" ) {
281
                $this->assertEquals ("fetch.php?data=1&type=epub&id=2", $link->href);
282
                return;
283
            }
284
        }
285
        $this->fail ();
286
    }
287
288
    public function testGetThumbnailNotNeeded ()
289
    {
290
        $book = Book::getBookById(2);
291
292
        $this->assertFalse ($book->getThumbnail (NULL, NULL, NULL));
293
294
        // Current cover is 400*600
295
        $this->assertFalse ($book->getThumbnail (COVER_WIDTH, NULL, NULL));
296
        $this->assertFalse ($book->getThumbnail (COVER_WIDTH + 1, NULL, NULL));
297
        $this->assertFalse ($book->getThumbnail (NULL, COVER_HEIGHT, NULL));
298
        $this->assertFalse ($book->getThumbnail (NULL, COVER_HEIGHT + 1, NULL));
299
    }
300
301
    /**
302
     * @dataProvider providerThumbnail
303
     */
304
    public function testGetThumbnailByWidth ($width, $height, $expectedWidth, $expectedHeight)
305
    {
306
        $book = Book::getBookById(2);
307
308
        $this->assertTrue ($book->getThumbnail ($width, $height, TEST_THUMBNAIL));
309
310
        $size = GetImageSize(TEST_THUMBNAIL);
311
        $this->assertEquals ($expectedWidth, $size [0]);
312
        $this->assertEquals ($expectedHeight, $size [1]);
313
314
        unlink (TEST_THUMBNAIL);
315
    }
316
317
    public function providerThumbnail ()
318
    {
319
        return array (
320
            array (164, NULL, 164, 246),
321
            array (NULL, 164, 109, 164)
322
        );
323
    }
324
325
    public function testGetMostInterestingDataToSendToKindle_WithMOBI ()
326
    {
327
        // Get Alice (available as MOBI, PDF, EPUB in that order)
328
        $book = Book::getBookById(17);
329
        $data = $book->GetMostInterestingDataToSendToKindle ();
330
        $this->assertEquals ("MOBI", $data->format);
331
    }
332
333
    public function testGetMostInterestingDataToSendToKindle_WithPdf ()
334
    {
335
        // Get Alice (available as MOBI, PDF, EPUB in that order)
336
        $book = Book::getBookById(17);
337
        $book->GetMostInterestingDataToSendToKindle ();
338
        array_shift ($book->datas);
339
        $data = $book->GetMostInterestingDataToSendToKindle ();
340
        $this->assertEquals ("PDF", $data->format);
341
    }
342
343
    public function testGetMostInterestingDataToSendToKindle_WithEPUB ()
344
    {
345
        // Get Alice (available as MOBI, PDF, EPUB in that order)
346
        $book = Book::getBookById(17);
347
        $book->GetMostInterestingDataToSendToKindle ();
348
        array_shift ($book->datas);
349
        array_shift ($book->datas);
350
        $data = $book->GetMostInterestingDataToSendToKindle ();
351
        $this->assertEquals ("EPUB", $data->format);
352
    }
353
354
    public function testGetDataById ()
355
    {
356
        global $config;
357
358
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
359
        $book = Book::getBookById(17);
360
        $mobi = $book->getDataById (17);
361
        $this->assertEquals ("MOBI", $mobi->format);
362
        $epub = $book->getDataById (20);
363
        $this->assertEquals ("EPUB", $epub->format);
364
        $this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.epub", $epub->getUpdatedFilenameEpub ());
365
        $this->assertEquals ("Carroll, Lewis - Alice's Adventures in Wonderland.kepub.epub", $epub->getUpdatedFilenameKepub ());
366
        $this->assertEquals (dirname(__FILE__) . "/BaseWithSomeBooks/Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub", $epub->getLocalPath ());
367
368
        $config['cops_use_url_rewriting'] = "1";
369
        $config['cops_provide_kepub'] = "1";
370
        $_SERVER["HTTP_USER_AGENT"] = "Kobo";
371
        $this->assertEquals ("download/20/Carroll%2C%20Lewis%20-%20Alice%27s%20Adventures%20in%20Wonderland.kepub.epub", $epub->getHtmlLink ());
372
        $this->assertEquals ("download/17/Alice%27s%20Adventures%20in%20Wonderland%20-%20Lewis%20Carroll.mobi", $mobi->getHtmlLink ());
373
        $_SERVER["HTTP_USER_AGENT"] = "Firefox";
374
        $this->assertEquals ("download/20/Alice%27s%20Adventures%20in%20Wonderland%20-%20Lewis%20Carroll.epub", $epub->getHtmlLink ());
375
        $config['cops_use_url_rewriting'] = "0";
376
        $this->assertEquals ("fetch.php?data=20&type=epub&id=17", $epub->getHtmlLink ());
377
    }
378
379
    public function testGetFilePath_Cover () {
380
        $book = Book::getBookById(17);
381
382
        $this->assertEquals ("Lewis Carroll/Alice's Adventures in Wonderland (17)/cover.jpg", $book->getFilePath ("jpg", NULL, true));
383
    }
384
385
    public function testGetFilePath_Epub () {
386
        $book = Book::getBookById(17);
387
388
        $this->assertEquals ("Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.epub", $book->getFilePath ("epub", 20, true));
389
    }
390
391
    public function testGetFilePath_Mobi () {
392
        $book = Book::getBookById(17);
393
394
        $this->assertEquals ("Lewis Carroll/Alice's Adventures in Wonderland (17)/Alice's Adventures in Wonderland - Lewis Carroll.mobi", $book->getFilePath ("mobi", 17, true));
395
    }
396
397
    public function testGetDataFormat_EPUB () {
398
        $book = Book::getBookById(17);
399
400
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
401
        $data = $book->getDataFormat ("EPUB");
402
        $this->assertEquals (20, $data->id);
403
    }
404
405
    public function testGetDataFormat_MOBI () {
406
        $book = Book::getBookById(17);
407
408
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
409
        $data = $book->getDataFormat ("MOBI");
410
        $this->assertEquals (17, $data->id);
411
    }
412
413
    public function testGetDataFormat_PDF () {
414
        $book = Book::getBookById(17);
415
416
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
417
        $data = $book->getDataFormat ("PDF");
418
        $this->assertEquals (19, $data->id);
419
    }
420
421
    public function testGetDataFormat_NonAvailable () {
422
        $book = Book::getBookById(17);
423
424
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
425
        $this->assertFalse ($book->getDataFormat ("FB2"));
426
    }
427
428
    public function testGetMimeType_EPUB () {
429
        $book = Book::getBookById(17);
430
431
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
432
        $data = $book->getDataFormat ("EPUB");
433
        $this->assertEquals ("application/epub+zip", $data->getMimeType ());
434
    }
435
436
    public function testGetMimeType_MOBI () {
437
        $book = Book::getBookById(17);
438
439
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
440
        $data = $book->getDataFormat ("MOBI");
441
        $this->assertEquals ("application/x-mobipocket-ebook", $data->getMimeType ());
442
    }
443
444
    public function testGetMimeType_PDF  () {
445
        $book = Book::getBookById(17);
446
447
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
448
        $data = $book->getDataFormat ("PDF");
449
        $this->assertEquals ("application/pdf", $data->getMimeType ());
450
    }
451
452
    public function testGetMimeType_Finfo () {
453
        $book = Book::getBookById(17);
454
455
        // Get Alice MOBI=>17, PDF=>19, EPUB=>20
456
        $data = $book->getDataFormat ("PDF");
457
        $this->assertEquals ("application/pdf", $data->getMimeType ());
458
459
        // Alter a data to make a test for finfo_file if enabled
460
        $data->extension = "ico";
461
        $data->format = "ICO";
462
        $data->name = "favicon";
463
        $data->book->path = realpath (dirname(__FILE__) . "/../");
464
        if (function_exists('finfo_open') === true) {
465
            $this->assertEquals ("image/x-icon", $data->getMimeType ());
466
        } else {
467
            $this->assertEquals ("application/octet-stream", $data->getMimeType ());
468
        }
469
    }
470
471
    public function testTypeaheadSearch_Tag ()
472
    {
473
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
474
        $_GET["query"] = "fic";
475
        $_GET["search"] = "1";
476
477
        $array = JSONRenderer::getJson ();
478
479
        $this->assertCount (3, $array);
480
        $this->assertEquals ("2 tags", $array[0]["title"]);
481
        $this->assertEquals ("Fiction", $array[1]["title"]);
482
        $this->assertEquals ("Science Fiction", $array[2]["title"]);
483
484
        $_GET["query"] = NULL;
485
        $_GET["search"] = NULL;
486
    }
487
488
    public function testTypeaheadSearch_BookAndAuthor ()
489
    {
490
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
491
        $_GET["query"] = "car";
492
        $_GET["search"] = "1";
493
494
        $array = JSONRenderer::getJson ();
495
496
        $this->assertCount (4, $array);
497
        $this->assertEquals ("1 book", $array[0]["title"]);
498
        $this->assertEquals ("A Study in Scarlet", $array[1]["title"]);
499
        $this->assertEquals ("1 author", $array[2]["title"]);
500
        $this->assertEquals ("Carroll, Lewis", $array[3]["title"]);
501
502
        $_GET["query"] = NULL;
503
        $_GET["search"] = NULL;
504
    }
505
506
    public function testTypeaheadSearch_AuthorAndSeries ()
507
    {
508
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
509
        $_GET["query"] = "art";
510
        $_GET["search"] = "1";
511
512
        $array = JSONRenderer::getJson ();
513
514
        $this->assertCount (5, $array);
515
        $this->assertEquals ("1 author", $array[0]["title"]);
516
        $this->assertEquals ("Doyle, Arthur Conan", $array[1]["title"]);
517
        $this->assertEquals ("2 series", $array[2]["title"]);
518
        $this->assertEquals ("D'Artagnan Romances", $array[3]["title"]);
519
520
        $_GET["query"] = NULL;
521
        $_GET["search"] = NULL;
522
    }
523
524
    public function testTypeaheadSearch_Publisher ()
525
    {
526
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
527
        $_GET["query"] = "Macmillan";
528
        $_GET["search"] = "1";
529
530
        $array = JSONRenderer::getJson ();
531
532
        $this->assertCount (3, $array);
533
        $this->assertEquals ("2 publishers", $array[0]["title"]);
534
        $this->assertEquals ("Macmillan and Co. London", $array[1]["title"]);
535
        $this->assertEquals ("Macmillan Publishers USA", $array[2]["title"]);
536
537
        $_GET["query"] = NULL;
538
        $_GET["search"] = NULL;
539
    }
540
541
    public function testTypeaheadSearchWithIgnored_SingleCategory ()
542
    {
543
        global $config;
544
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
545
        $_GET["query"] = "car";
546
        $_GET["search"] = "1";
547
548
        $config ['cops_ignored_categories'] = array ("author");
549
        $array = JSONRenderer::getJson ();
550
551
        $this->assertCount (2, $array);
552
        $this->assertEquals ("1 book", $array[0]["title"]);
553
        $this->assertEquals ("A Study in Scarlet", $array[1]["title"]);
554
555
        $_GET["query"] = NULL;
556
        $_GET["search"] = NULL;
557
    }
558
559
    public function testTypeaheadSearchWithIgnored_MultipleCategory ()
560
    {
561
        global $config;
562
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
563
        $_GET["query"] = "art";
564
        $_GET["search"] = "1";
565
566
        $config ['cops_ignored_categories'] = array ("series");
567
        $array = JSONRenderer::getJson ();
568
569
        $this->assertCount (2, $array);
570
        $this->assertEquals ("1 author", $array[0]["title"]);
571
        $this->assertEquals ("Doyle, Arthur Conan", $array[1]["title"]);
572
573
        $_GET["query"] = NULL;
574
        $_GET["search"] = NULL;
575
    }
576
577
    public function testTypeaheadSearchMultiDatabase ()
578
    {
579
        global $config;
580
        $_GET["page"] = Base::PAGE_OPENSEARCH_QUERY;
581
        $_GET["query"] = "art";
582
        $_GET["search"] = "1";
583
        $_GET["multi"] = "1";
584
585
        $config['calibre_directory'] = array ("Some books" => dirname(__FILE__) . "/BaseWithSomeBooks/",
586
                                              "One book" => dirname(__FILE__) . "/BaseWithOneBook/");
587
588
        $array = JSONRenderer::getJson ();
589
590
        $this->assertCount (5, $array);
591
        $this->assertEquals ("Some books", $array[0]["title"]);
592
        $this->assertEquals ("1 author", $array[1]["title"]);
593
        $this->assertEquals ("2 series", $array[2]["title"]);
594
        $this->assertEquals ("One book", $array[3]["title"]);
595
        $this->assertEquals ("1 book", $array[4]["title"]);
596
597
        $_GET["query"] = NULL;
598
        $_GET["search"] = NULL;
599
    }
600
601
    public function tearDown () {
602
        Base::clearDb ();
603
    }
604
605
}