diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-22 16:21:03 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-05 17:54:42 +0100 |
commit | b3bd8c3e8d367975980043e772f7cd78b7f96bc6 (patch) | |
tree | ec79899ea564c093d8b0578f3e614881a4ea7c3d /tests/netscape | |
parent | 48df9f45b8c4b2995c1e04146071628668531b37 (diff) | |
download | Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.gz Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.zst Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.zip |
Feature: support any tag separator
So it allows to have multiple words tags.
Breaking change: commas ',' are no longer a default separator.
Fixes #594
Diffstat (limited to 'tests/netscape')
-rw-r--r-- | tests/netscape/BookmarkImportTest.php | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/netscape/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php index c526d5c8..6856ebca 100644 --- a/tests/netscape/BookmarkImportTest.php +++ b/tests/netscape/BookmarkImportTest.php | |||
@@ -531,7 +531,7 @@ class BookmarkImportTest extends TestCase | |||
531 | { | 531 | { |
532 | $post = array( | 532 | $post = array( |
533 | 'privacy' => 'public', | 533 | 'privacy' => 'public', |
534 | 'default_tags' => 'tag1,tag2 tag3' | 534 | 'default_tags' => 'tag1 tag2 tag3' |
535 | ); | 535 | ); |
536 | $files = file2array('netscape_basic.htm'); | 536 | $files = file2array('netscape_basic.htm'); |
537 | $this->assertStringMatchesFormat( | 537 | $this->assertStringMatchesFormat( |
@@ -552,7 +552,7 @@ class BookmarkImportTest extends TestCase | |||
552 | { | 552 | { |
553 | $post = array( | 553 | $post = array( |
554 | 'privacy' => 'public', | 554 | 'privacy' => 'public', |
555 | 'default_tags' => 'tag1&,tag2 "tag3"' | 555 | 'default_tags' => 'tag1& tag2 "tag3"' |
556 | ); | 556 | ); |
557 | $files = file2array('netscape_basic.htm'); | 557 | $files = file2array('netscape_basic.htm'); |
558 | $this->assertStringMatchesFormat( | 558 | $this->assertStringMatchesFormat( |
@@ -573,6 +573,43 @@ class BookmarkImportTest extends TestCase | |||
573 | } | 573 | } |
574 | 574 | ||
575 | /** | 575 | /** |
576 | * Add user-specified tags to all imported bookmarks | ||
577 | */ | ||
578 | public function testSetDefaultTagsWithCustomSeparator() | ||
579 | { | ||
580 | $separator = '@'; | ||
581 | $this->conf->set('general.tags_separator', $separator); | ||
582 | $post = [ | ||
583 | 'privacy' => 'public', | ||
584 | 'default_tags' => 'tag1@tag2@tag3@multiple words tag' | ||
585 | ]; | ||
586 | $files = file2array('netscape_basic.htm'); | ||
587 | $this->assertStringMatchesFormat( | ||
588 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | ||
589 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | ||
590 | $this->netscapeBookmarkUtils->import($post, $files) | ||
591 | ); | ||
592 | $this->assertEquals(2, $this->bookmarkService->count()); | ||
593 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | ||
594 | $this->assertEquals( | ||
595 | 'tag1@tag2@tag3@multiple words tag@private@secret', | ||
596 | $this->bookmarkService->get(0)->getTagsString($separator) | ||
597 | ); | ||
598 | $this->assertEquals( | ||
599 | ['tag1', 'tag2', 'tag3', 'multiple words tag', 'private', 'secret'], | ||
600 | $this->bookmarkService->get(0)->getTags() | ||
601 | ); | ||
602 | $this->assertEquals( | ||
603 | 'tag1@tag2@tag3@multiple words tag@public@hello@world', | ||
604 | $this->bookmarkService->get(1)->getTagsString($separator) | ||
605 | ); | ||
606 | $this->assertEquals( | ||
607 | ['tag1', 'tag2', 'tag3', 'multiple words tag', 'public', 'hello', 'world'], | ||
608 | $this->bookmarkService->get(1)->getTags() | ||
609 | ); | ||
610 | } | ||
611 | |||
612 | /** | ||
576 | * Ensure each imported bookmark has a unique id | 613 | * Ensure each imported bookmark has a unique id |
577 | * | 614 | * |
578 | * See https://github.com/shaarli/Shaarli/issues/351 | 615 | * See https://github.com/shaarli/Shaarli/issues/351 |