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/bookmark/BookmarkTest.php | |
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/bookmark/BookmarkTest.php')
-rw-r--r-- | tests/bookmark/BookmarkTest.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/bookmark/BookmarkTest.php b/tests/bookmark/BookmarkTest.php index 4c1ae25d..cb91b26b 100644 --- a/tests/bookmark/BookmarkTest.php +++ b/tests/bookmark/BookmarkTest.php | |||
@@ -79,6 +79,23 @@ class BookmarkTest extends TestCase | |||
79 | } | 79 | } |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Test fromArray() with a link with a custom tags separator | ||
83 | */ | ||
84 | public function testFromArrayCustomTagsSeparator() | ||
85 | { | ||
86 | $data = [ | ||
87 | 'id' => 1, | ||
88 | 'tags' => ['tag1', 'tag2', 'chair'], | ||
89 | ]; | ||
90 | |||
91 | $bookmark = (new Bookmark())->fromArray($data, '@'); | ||
92 | $this->assertEquals($data['id'], $bookmark->getId()); | ||
93 | $this->assertEquals($data['tags'], $bookmark->getTags()); | ||
94 | $this->assertEquals('tag1@tag2@chair', $bookmark->getTagsString('@')); | ||
95 | } | ||
96 | |||
97 | |||
98 | /** | ||
82 | * Test validate() with a valid minimal bookmark | 99 | * Test validate() with a valid minimal bookmark |
83 | */ | 100 | */ |
84 | public function testValidateValidFullBookmark() | 101 | public function testValidateValidFullBookmark() |
@@ -252,7 +269,7 @@ class BookmarkTest extends TestCase | |||
252 | { | 269 | { |
253 | $bookmark = new Bookmark(); | 270 | $bookmark = new Bookmark(); |
254 | 271 | ||
255 | $str = 'tag1 tag2 tag3.tag3-2, tag4 , -tag5 '; | 272 | $str = 'tag1 tag2 tag3.tag3-2 tag4 -tag5 '; |
256 | $bookmark->setTagsString($str); | 273 | $bookmark->setTagsString($str); |
257 | $this->assertEquals( | 274 | $this->assertEquals( |
258 | [ | 275 | [ |
@@ -276,9 +293,9 @@ class BookmarkTest extends TestCase | |||
276 | $array = [ | 293 | $array = [ |
277 | 'tag1 ', | 294 | 'tag1 ', |
278 | ' tag2', | 295 | ' tag2', |
279 | 'tag3.tag3-2,', | 296 | 'tag3.tag3-2', |
280 | ', tag4', | 297 | ' tag4', |
281 | ', ', | 298 | ' ', |
282 | '-tag5 ', | 299 | '-tag5 ', |
283 | ]; | 300 | ]; |
284 | $bookmark->setTags($array); | 301 | $bookmark->setTags($array); |