aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam+github@flibidi.net>2017-10-08 16:35:57 +0200
committerGitHub <noreply@github.com>2017-10-08 16:35:57 +0200
commit9f32160c323e77237e4051056c1f1061586cc12e (patch)
treec8203cd553fa770f2067ce04d30579ee1aa2f60f /tests/NetscapeBookmarkUtils/BookmarkImportTest.php
parent0a496258af71ab77eacb9e7ccd27471a65b61fa0 (diff)
parent66e74d50d38a6fea8fc904a1746157633de7cc65 (diff)
downloadShaarli-9f32160c323e77237e4051056c1f1061586cc12e.tar.gz
Shaarli-9f32160c323e77237e4051056c1f1061586cc12e.tar.zst
Shaarli-9f32160c323e77237e4051056c1f1061586cc12e.zip
Merge pull request #992 from ArthurHoaro/feature/import-history
Don't write History for link import
Diffstat (limited to 'tests/NetscapeBookmarkUtils/BookmarkImportTest.php')
-rw-r--r--tests/NetscapeBookmarkUtils/BookmarkImportTest.php81
1 files changed, 38 insertions, 43 deletions
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
index 5fc1d1e8..4961aa2c 100644
--- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
+++ b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
@@ -132,8 +132,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
132 public function testImportInternetExplorerEncoding() 132 public function testImportInternetExplorerEncoding()
133 { 133 {
134 $files = file2array('internet_explorer_encoding.htm'); 134 $files = file2array('internet_explorer_encoding.htm');
135 $this->assertEquals( 135 $this->assertStringMatchesFormat(
136 'File internet_explorer_encoding.htm (356 bytes) was successfully processed:' 136 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
137 .' 1 links imported, 0 links overwritten, 0 links skipped.', 137 .' 1 links imported, 0 links overwritten, 0 links skipped.',
138 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history) 138 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history)
139 ); 139 );
@@ -161,8 +161,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
161 public function testImportNested() 161 public function testImportNested()
162 { 162 {
163 $files = file2array('netscape_nested.htm'); 163 $files = file2array('netscape_nested.htm');
164 $this->assertEquals( 164 $this->assertStringMatchesFormat(
165 'File netscape_nested.htm (1337 bytes) was successfully processed:' 165 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
166 .' 8 links imported, 0 links overwritten, 0 links skipped.', 166 .' 8 links imported, 0 links overwritten, 0 links skipped.',
167 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history) 167 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history)
168 ); 168 );
@@ -283,8 +283,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
283 public function testImportDefaultPrivacyNoPost() 283 public function testImportDefaultPrivacyNoPost()
284 { 284 {
285 $files = file2array('netscape_basic.htm'); 285 $files = file2array('netscape_basic.htm');
286 $this->assertEquals( 286 $this->assertStringMatchesFormat(
287 'File netscape_basic.htm (482 bytes) was successfully processed:' 287 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
288 .' 2 links imported, 0 links overwritten, 0 links skipped.', 288 .' 2 links imported, 0 links overwritten, 0 links skipped.',
289 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history) 289 NetscapeBookmarkUtils::import([], $files, $this->linkDb, $this->conf, $this->history)
290 ); 290 );
@@ -328,8 +328,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
328 { 328 {
329 $post = array('privacy' => 'default'); 329 $post = array('privacy' => 'default');
330 $files = file2array('netscape_basic.htm'); 330 $files = file2array('netscape_basic.htm');
331 $this->assertEquals( 331 $this->assertStringMatchesFormat(
332 'File netscape_basic.htm (482 bytes) was successfully processed:' 332 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
333 .' 2 links imported, 0 links overwritten, 0 links skipped.', 333 .' 2 links imported, 0 links overwritten, 0 links skipped.',
334 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 334 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
335 ); 335 );
@@ -372,8 +372,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
372 { 372 {
373 $post = array('privacy' => 'public'); 373 $post = array('privacy' => 'public');
374 $files = file2array('netscape_basic.htm'); 374 $files = file2array('netscape_basic.htm');
375 $this->assertEquals( 375 $this->assertStringMatchesFormat(
376 'File netscape_basic.htm (482 bytes) was successfully processed:' 376 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
377 .' 2 links imported, 0 links overwritten, 0 links skipped.', 377 .' 2 links imported, 0 links overwritten, 0 links skipped.',
378 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 378 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
379 ); 379 );
@@ -396,8 +396,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
396 { 396 {
397 $post = array('privacy' => 'private'); 397 $post = array('privacy' => 'private');
398 $files = file2array('netscape_basic.htm'); 398 $files = file2array('netscape_basic.htm');
399 $this->assertEquals( 399 $this->assertStringMatchesFormat(
400 'File netscape_basic.htm (482 bytes) was successfully processed:' 400 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
401 .' 2 links imported, 0 links overwritten, 0 links skipped.', 401 .' 2 links imported, 0 links overwritten, 0 links skipped.',
402 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 402 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
403 ); 403 );
@@ -422,8 +422,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
422 422
423 // import links as private 423 // import links as private
424 $post = array('privacy' => 'private'); 424 $post = array('privacy' => 'private');
425 $this->assertEquals( 425 $this->assertStringMatchesFormat(
426 'File netscape_basic.htm (482 bytes) was successfully processed:' 426 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
427 .' 2 links imported, 0 links overwritten, 0 links skipped.', 427 .' 2 links imported, 0 links overwritten, 0 links skipped.',
428 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 428 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
429 ); 429 );
@@ -442,8 +442,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
442 'privacy' => 'public', 442 'privacy' => 'public',
443 'overwrite' => 'true' 443 'overwrite' => 'true'
444 ); 444 );
445 $this->assertEquals( 445 $this->assertStringMatchesFormat(
446 'File netscape_basic.htm (482 bytes) was successfully processed:' 446 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
447 .' 2 links imported, 2 links overwritten, 0 links skipped.', 447 .' 2 links imported, 2 links overwritten, 0 links skipped.',
448 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 448 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
449 ); 449 );
@@ -468,8 +468,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
468 468
469 // import links as public 469 // import links as public
470 $post = array('privacy' => 'public'); 470 $post = array('privacy' => 'public');
471 $this->assertEquals( 471 $this->assertStringMatchesFormat(
472 'File netscape_basic.htm (482 bytes) was successfully processed:' 472 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
473 .' 2 links imported, 0 links overwritten, 0 links skipped.', 473 .' 2 links imported, 0 links overwritten, 0 links skipped.',
474 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 474 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
475 ); 475 );
@@ -489,8 +489,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
489 'privacy' => 'private', 489 'privacy' => 'private',
490 'overwrite' => 'true' 490 'overwrite' => 'true'
491 ); 491 );
492 $this->assertEquals( 492 $this->assertStringMatchesFormat(
493 'File netscape_basic.htm (482 bytes) was successfully processed:' 493 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
494 .' 2 links imported, 2 links overwritten, 0 links skipped.', 494 .' 2 links imported, 2 links overwritten, 0 links skipped.',
495 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 495 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
496 ); 496 );
@@ -513,8 +513,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
513 { 513 {
514 $post = array('privacy' => 'public'); 514 $post = array('privacy' => 'public');
515 $files = file2array('netscape_basic.htm'); 515 $files = file2array('netscape_basic.htm');
516 $this->assertEquals( 516 $this->assertStringMatchesFormat(
517 'File netscape_basic.htm (482 bytes) was successfully processed:' 517 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
518 .' 2 links imported, 0 links overwritten, 0 links skipped.', 518 .' 2 links imported, 0 links overwritten, 0 links skipped.',
519 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 519 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
520 ); 520 );
@@ -523,8 +523,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
523 523
524 // re-import as private, DO NOT enable overwriting 524 // re-import as private, DO NOT enable overwriting
525 $post = array('privacy' => 'private'); 525 $post = array('privacy' => 'private');
526 $this->assertEquals( 526 $this->assertStringMatchesFormat(
527 'File netscape_basic.htm (482 bytes) was successfully processed:' 527 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
528 .' 0 links imported, 0 links overwritten, 2 links skipped.', 528 .' 0 links imported, 0 links overwritten, 2 links skipped.',
529 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 529 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
530 ); 530 );
@@ -542,8 +542,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
542 'default_tags' => 'tag1,tag2 tag3' 542 'default_tags' => 'tag1,tag2 tag3'
543 ); 543 );
544 $files = file2array('netscape_basic.htm'); 544 $files = file2array('netscape_basic.htm');
545 $this->assertEquals( 545 $this->assertStringMatchesFormat(
546 'File netscape_basic.htm (482 bytes) was successfully processed:' 546 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
547 .' 2 links imported, 0 links overwritten, 0 links skipped.', 547 .' 2 links imported, 0 links overwritten, 0 links skipped.',
548 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 548 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
549 ); 549 );
@@ -569,8 +569,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
569 'default_tags' => 'tag1&,tag2 "tag3"' 569 'default_tags' => 'tag1&,tag2 "tag3"'
570 ); 570 );
571 $files = file2array('netscape_basic.htm'); 571 $files = file2array('netscape_basic.htm');
572 $this->assertEquals( 572 $this->assertStringMatchesFormat(
573 'File netscape_basic.htm (482 bytes) was successfully processed:' 573 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
574 .' 2 links imported, 0 links overwritten, 0 links skipped.', 574 .' 2 links imported, 0 links overwritten, 0 links skipped.',
575 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history) 575 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history)
576 ); 576 );
@@ -594,8 +594,8 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
594 public function testImportSameDate() 594 public function testImportSameDate()
595 { 595 {
596 $files = file2array('same_date.htm'); 596 $files = file2array('same_date.htm');
597 $this->assertEquals( 597 $this->assertStringMatchesFormat(
598 'File same_date.htm (453 bytes) was successfully processed:' 598 'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
599 .' 3 links imported, 0 links overwritten, 0 links skipped.', 599 .' 3 links imported, 0 links overwritten, 0 links skipped.',
600 NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf, $this->history) 600 NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf, $this->history)
601 ); 601 );
@@ -622,24 +622,19 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase
622 'overwrite' => 'true', 622 'overwrite' => 'true',
623 ]; 623 ];
624 $files = file2array('netscape_basic.htm'); 624 $files = file2array('netscape_basic.htm');
625 $nbLinks = 2;
626 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history); 625 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history);
627 $history = $this->history->getHistory(); 626 $history = $this->history->getHistory();
628 $this->assertEquals($nbLinks, count($history)); 627 $this->assertEquals(1, count($history));
629 foreach ($history as $value) { 628 $this->assertEquals(History::IMPORT, $history[0]['event']);
630 $this->assertEquals(History::CREATED, $value['event']); 629 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
631 $this->assertTrue(new DateTime('-5 seconds') < $value['datetime']);
632 $this->assertTrue(is_int($value['id']));
633 }
634 630
635 // re-import as private, enable overwriting 631 // re-import as private, enable overwriting
636 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history); 632 NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf, $this->history);
637 $history = $this->history->getHistory(); 633 $history = $this->history->getHistory();
638 $this->assertEquals($nbLinks * 2, count($history)); 634 $this->assertEquals(2, count($history));
639 for ($i = 0 ; $i < $nbLinks ; $i++) { 635 $this->assertEquals(History::IMPORT, $history[0]['event']);
640 $this->assertEquals(History::UPDATED, $history[$i]['event']); 636 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
641 $this->assertTrue(new DateTime('-5 seconds') < $history[$i]['datetime']); 637 $this->assertEquals(History::IMPORT, $history[1]['event']);
642 $this->assertTrue(is_int($history[$i]['id'])); 638 $this->assertTrue(new DateTime('-5 seconds') < $history[1]['datetime']);
643 }
644 } 639 }
645} 640}