diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/NetscapeBookmarkUtils/BookmarkImportTest.php | 42 | ||||
-rw-r--r-- | tests/utils/config/configJson.json.php | 2 |
2 files changed, 26 insertions, 18 deletions
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php index 0ca07eac..5925a8e1 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php +++ b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | require_once 'application/NetscapeBookmarkUtils.php'; | 3 | require_once 'application/NetscapeBookmarkUtils.php'; |
4 | 4 | ||
5 | use Shaarli\Config\ConfigManager; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Utility function to load a file's metadata in a $_FILES-like array | 8 | * Utility function to load a file's metadata in a $_FILES-like array |
@@ -43,6 +44,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
43 | protected $pagecache = 'tests'; | 44 | protected $pagecache = 'tests'; |
44 | 45 | ||
45 | /** | 46 | /** |
47 | * @var ConfigManager instance. | ||
48 | */ | ||
49 | protected $conf; | ||
50 | |||
51 | /** | ||
46 | * @var string Save the current timezone. | 52 | * @var string Save the current timezone. |
47 | */ | 53 | */ |
48 | protected static $defaultTimeZone; | 54 | protected static $defaultTimeZone; |
@@ -65,6 +71,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
65 | // start with an empty datastore | 71 | // start with an empty datastore |
66 | file_put_contents(self::$testDatastore, '<?php /* S7QysKquBQA= */ ?>'); | 72 | file_put_contents(self::$testDatastore, '<?php /* S7QysKquBQA= */ ?>'); |
67 | $this->linkDb = new LinkDB(self::$testDatastore, true, false); | 73 | $this->linkDb = new LinkDB(self::$testDatastore, true, false); |
74 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | ||
75 | $this->conf->set('resource.page_cache', $this->pagecache); | ||
68 | } | 76 | } |
69 | 77 | ||
70 | public static function tearDownAfterClass() | 78 | public static function tearDownAfterClass() |
@@ -81,7 +89,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
81 | $this->assertEquals( | 89 | $this->assertEquals( |
82 | 'File empty.htm (0 bytes) has an unknown file format.' | 90 | 'File empty.htm (0 bytes) has an unknown file format.' |
83 | .' Nothing was imported.', | 91 | .' Nothing was imported.', |
84 | NetscapeBookmarkUtils::import(NULL, $files, NULL, NULL) | 92 | NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf) |
85 | ); | 93 | ); |
86 | $this->assertEquals(0, count($this->linkDb)); | 94 | $this->assertEquals(0, count($this->linkDb)); |
87 | } | 95 | } |
@@ -94,7 +102,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
94 | $files = file2array('no_doctype.htm'); | 102 | $files = file2array('no_doctype.htm'); |
95 | $this->assertEquals( | 103 | $this->assertEquals( |
96 | 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', | 104 | 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', |
97 | NetscapeBookmarkUtils::import(NULL, $files, NULL, NULL) | 105 | NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf) |
98 | ); | 106 | ); |
99 | $this->assertEquals(0, count($this->linkDb)); | 107 | $this->assertEquals(0, count($this->linkDb)); |
100 | } | 108 | } |
@@ -108,7 +116,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
108 | $this->assertEquals( | 116 | $this->assertEquals( |
109 | 'File internet_explorer_encoding.htm (356 bytes) was successfully processed:' | 117 | 'File internet_explorer_encoding.htm (356 bytes) was successfully processed:' |
110 | .' 1 links imported, 0 links overwritten, 0 links skipped.', | 118 | .' 1 links imported, 0 links overwritten, 0 links skipped.', |
111 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) | 119 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) |
112 | ); | 120 | ); |
113 | $this->assertEquals(1, count($this->linkDb)); | 121 | $this->assertEquals(1, count($this->linkDb)); |
114 | $this->assertEquals(0, count_private($this->linkDb)); | 122 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -137,7 +145,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
137 | $this->assertEquals( | 145 | $this->assertEquals( |
138 | 'File netscape_nested.htm (1337 bytes) was successfully processed:' | 146 | 'File netscape_nested.htm (1337 bytes) was successfully processed:' |
139 | .' 8 links imported, 0 links overwritten, 0 links skipped.', | 147 | .' 8 links imported, 0 links overwritten, 0 links skipped.', |
140 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) | 148 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) |
141 | ); | 149 | ); |
142 | $this->assertEquals(8, count($this->linkDb)); | 150 | $this->assertEquals(8, count($this->linkDb)); |
143 | $this->assertEquals(2, count_private($this->linkDb)); | 151 | $this->assertEquals(2, count_private($this->linkDb)); |
@@ -259,7 +267,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
259 | $this->assertEquals( | 267 | $this->assertEquals( |
260 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 268 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
261 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 269 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
262 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) | 270 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) |
263 | ); | 271 | ); |
264 | 272 | ||
265 | $this->assertEquals(2, count($this->linkDb)); | 273 | $this->assertEquals(2, count($this->linkDb)); |
@@ -304,7 +312,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
304 | $this->assertEquals( | 312 | $this->assertEquals( |
305 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 313 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
306 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 314 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
307 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 315 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
308 | ); | 316 | ); |
309 | $this->assertEquals(2, count($this->linkDb)); | 317 | $this->assertEquals(2, count($this->linkDb)); |
310 | $this->assertEquals(1, count_private($this->linkDb)); | 318 | $this->assertEquals(1, count_private($this->linkDb)); |
@@ -348,7 +356,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
348 | $this->assertEquals( | 356 | $this->assertEquals( |
349 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 357 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
350 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 358 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
351 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 359 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
352 | ); | 360 | ); |
353 | $this->assertEquals(2, count($this->linkDb)); | 361 | $this->assertEquals(2, count($this->linkDb)); |
354 | $this->assertEquals(0, count_private($this->linkDb)); | 362 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -372,7 +380,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
372 | $this->assertEquals( | 380 | $this->assertEquals( |
373 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 381 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
374 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 382 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
375 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 383 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
376 | ); | 384 | ); |
377 | $this->assertEquals(2, count($this->linkDb)); | 385 | $this->assertEquals(2, count($this->linkDb)); |
378 | $this->assertEquals(2, count_private($this->linkDb)); | 386 | $this->assertEquals(2, count_private($this->linkDb)); |
@@ -398,7 +406,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
398 | $this->assertEquals( | 406 | $this->assertEquals( |
399 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 407 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
400 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 408 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
401 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 409 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
402 | ); | 410 | ); |
403 | $this->assertEquals(2, count($this->linkDb)); | 411 | $this->assertEquals(2, count($this->linkDb)); |
404 | $this->assertEquals(2, count_private($this->linkDb)); | 412 | $this->assertEquals(2, count_private($this->linkDb)); |
@@ -418,7 +426,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
418 | $this->assertEquals( | 426 | $this->assertEquals( |
419 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 427 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
420 | .' 2 links imported, 2 links overwritten, 0 links skipped.', | 428 | .' 2 links imported, 2 links overwritten, 0 links skipped.', |
421 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 429 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
422 | ); | 430 | ); |
423 | $this->assertEquals(2, count($this->linkDb)); | 431 | $this->assertEquals(2, count($this->linkDb)); |
424 | $this->assertEquals(0, count_private($this->linkDb)); | 432 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -444,7 +452,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
444 | $this->assertEquals( | 452 | $this->assertEquals( |
445 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 453 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
446 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 454 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
447 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 455 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
448 | ); | 456 | ); |
449 | $this->assertEquals(2, count($this->linkDb)); | 457 | $this->assertEquals(2, count($this->linkDb)); |
450 | $this->assertEquals(0, count_private($this->linkDb)); | 458 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -465,7 +473,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
465 | $this->assertEquals( | 473 | $this->assertEquals( |
466 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 474 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
467 | .' 2 links imported, 2 links overwritten, 0 links skipped.', | 475 | .' 2 links imported, 2 links overwritten, 0 links skipped.', |
468 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 476 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
469 | ); | 477 | ); |
470 | $this->assertEquals(2, count($this->linkDb)); | 478 | $this->assertEquals(2, count($this->linkDb)); |
471 | $this->assertEquals(2, count_private($this->linkDb)); | 479 | $this->assertEquals(2, count_private($this->linkDb)); |
@@ -489,7 +497,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
489 | $this->assertEquals( | 497 | $this->assertEquals( |
490 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 498 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
491 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 499 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
492 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 500 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
493 | ); | 501 | ); |
494 | $this->assertEquals(2, count($this->linkDb)); | 502 | $this->assertEquals(2, count($this->linkDb)); |
495 | $this->assertEquals(0, count_private($this->linkDb)); | 503 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -499,7 +507,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
499 | $this->assertEquals( | 507 | $this->assertEquals( |
500 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 508 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
501 | .' 0 links imported, 0 links overwritten, 2 links skipped.', | 509 | .' 0 links imported, 0 links overwritten, 2 links skipped.', |
502 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 510 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
503 | ); | 511 | ); |
504 | $this->assertEquals(2, count($this->linkDb)); | 512 | $this->assertEquals(2, count($this->linkDb)); |
505 | $this->assertEquals(0, count_private($this->linkDb)); | 513 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -518,7 +526,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
518 | $this->assertEquals( | 526 | $this->assertEquals( |
519 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 527 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
520 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 528 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
521 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 529 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
522 | ); | 530 | ); |
523 | $this->assertEquals(2, count($this->linkDb)); | 531 | $this->assertEquals(2, count($this->linkDb)); |
524 | $this->assertEquals(0, count_private($this->linkDb)); | 532 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -545,7 +553,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
545 | $this->assertEquals( | 553 | $this->assertEquals( |
546 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | 554 | 'File netscape_basic.htm (482 bytes) was successfully processed:' |
547 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 555 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
548 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->pagecache) | 556 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) |
549 | ); | 557 | ); |
550 | $this->assertEquals(2, count($this->linkDb)); | 558 | $this->assertEquals(2, count($this->linkDb)); |
551 | $this->assertEquals(0, count_private($this->linkDb)); | 559 | $this->assertEquals(0, count_private($this->linkDb)); |
@@ -570,7 +578,7 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
570 | $this->assertEquals( | 578 | $this->assertEquals( |
571 | 'File same_date.htm (453 bytes) was successfully processed:' | 579 | 'File same_date.htm (453 bytes) was successfully processed:' |
572 | .' 3 links imported, 0 links overwritten, 0 links skipped.', | 580 | .' 3 links imported, 0 links overwritten, 0 links skipped.', |
573 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) | 581 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) |
574 | ); | 582 | ); |
575 | $this->assertEquals(3, count($this->linkDb)); | 583 | $this->assertEquals(3, count($this->linkDb)); |
576 | $this->assertEquals(0, count_private($this->linkDb)); | 584 | $this->assertEquals(0, count_private($this->linkDb)); |
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php index 13d38c66..9c9288f3 100644 --- a/tests/utils/config/configJson.json.php +++ b/tests/utils/config/configJson.json.php | |||
@@ -24,7 +24,7 @@ | |||
24 | }, | 24 | }, |
25 | "resource": { | 25 | "resource": { |
26 | "datastore": "tests\/utils\/config\/datastore.php", | 26 | "datastore": "tests\/utils\/config\/datastore.php", |
27 | "data_dir": "tests\/utils\/config", | 27 | "data_dir": "sandbox/", |
28 | "raintpl_tpl": "tpl/" | 28 | "raintpl_tpl": "tpl/" |
29 | }, | 29 | }, |
30 | "plugins": { | 30 | "plugins": { |