diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-01-18 11:33:23 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-01-18 11:39:26 +0100 |
commit | a39acb2518f272df8a601af72c13eabe2719dcb8 (patch) | |
tree | fb8bda9de5bea9d73553c3d54610eb211d7de6fb /tests/formatter | |
parent | 3fb29fdda04ca86e04422d49b86cf646d53c4f9d (diff) | |
download | Shaarli-a39acb2518f272df8a601af72c13eabe2719dcb8.tar.gz Shaarli-a39acb2518f272df8a601af72c13eabe2719dcb8.tar.zst Shaarli-a39acb2518f272df8a601af72c13eabe2719dcb8.zip |
Fix an issue with private tags and fix nomarkdown tag
The new bookmark service wasn't handling private tags properly.
nomarkdown tag is now shown only for logged in user in bookmarks, and hidden for everyone in tag clouds/lists.
Fixes #726
Diffstat (limited to 'tests/formatter')
-rw-r--r-- | tests/formatter/BookmarkDefaultFormatterTest.php | 23 | ||||
-rw-r--r-- | tests/formatter/BookmarkMarkdownFormatterTest.php | 2 | ||||
-rw-r--r-- | tests/formatter/BookmarkRawFormatterTest.php | 2 | ||||
-rw-r--r-- | tests/formatter/FormatterFactoryTest.php | 2 |
4 files changed, 25 insertions, 4 deletions
diff --git a/tests/formatter/BookmarkDefaultFormatterTest.php b/tests/formatter/BookmarkDefaultFormatterTest.php index fe42a208..382a560e 100644 --- a/tests/formatter/BookmarkDefaultFormatterTest.php +++ b/tests/formatter/BookmarkDefaultFormatterTest.php | |||
@@ -29,7 +29,7 @@ class BookmarkDefaultFormatterTest extends TestCase | |||
29 | { | 29 | { |
30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); | 30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); |
31 | $this->conf = new ConfigManager(self::$testConf); | 31 | $this->conf = new ConfigManager(self::$testConf); |
32 | $this->formatter = new BookmarkDefaultFormatter($this->conf); | 32 | $this->formatter = new BookmarkDefaultFormatter($this->conf, true); |
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
@@ -153,4 +153,25 @@ class BookmarkDefaultFormatterTest extends TestCase | |||
153 | $link['description'] | 153 | $link['description'] |
154 | ); | 154 | ); |
155 | } | 155 | } |
156 | |||
157 | /** | ||
158 | * Make sure that private tags are properly filtered out when the user is logged out. | ||
159 | */ | ||
160 | public function testFormatTagListRemovePrivate(): void | ||
161 | { | ||
162 | $this->formatter = new BookmarkDefaultFormatter($this->conf, false); | ||
163 | |||
164 | $bookmark = new Bookmark(); | ||
165 | $bookmark->setId($id = 11); | ||
166 | $bookmark->setTags($tags = ['bookmark', '.private', 'othertag']); | ||
167 | |||
168 | $link = $this->formatter->format($bookmark); | ||
169 | |||
170 | unset($tags[1]); | ||
171 | $tags = array_values($tags); | ||
172 | |||
173 | $this->assertSame(11, $link['id']); | ||
174 | $this->assertSame($tags, $link['taglist']); | ||
175 | $this->assertSame(implode(' ', $tags), $link['tags']); | ||
176 | } | ||
156 | } | 177 | } |
diff --git a/tests/formatter/BookmarkMarkdownFormatterTest.php b/tests/formatter/BookmarkMarkdownFormatterTest.php index 0ca7f802..f1f12c04 100644 --- a/tests/formatter/BookmarkMarkdownFormatterTest.php +++ b/tests/formatter/BookmarkMarkdownFormatterTest.php | |||
@@ -29,7 +29,7 @@ class BookmarkMarkdownFormatterTest extends TestCase | |||
29 | { | 29 | { |
30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); | 30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); |
31 | $this->conf = new ConfigManager(self::$testConf); | 31 | $this->conf = new ConfigManager(self::$testConf); |
32 | $this->formatter = new BookmarkMarkdownFormatter($this->conf); | 32 | $this->formatter = new BookmarkMarkdownFormatter($this->conf, true); |
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
diff --git a/tests/formatter/BookmarkRawFormatterTest.php b/tests/formatter/BookmarkRawFormatterTest.php index ceb6fb73..4491b035 100644 --- a/tests/formatter/BookmarkRawFormatterTest.php +++ b/tests/formatter/BookmarkRawFormatterTest.php | |||
@@ -29,7 +29,7 @@ class BookmarkRawFormatterTest extends TestCase | |||
29 | { | 29 | { |
30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); | 30 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); |
31 | $this->conf = new ConfigManager(self::$testConf); | 31 | $this->conf = new ConfigManager(self::$testConf); |
32 | $this->formatter = new BookmarkRawFormatter($this->conf); | 32 | $this->formatter = new BookmarkRawFormatter($this->conf, true); |
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
diff --git a/tests/formatter/FormatterFactoryTest.php b/tests/formatter/FormatterFactoryTest.php index 317c0b2d..5adf3ffd 100644 --- a/tests/formatter/FormatterFactoryTest.php +++ b/tests/formatter/FormatterFactoryTest.php | |||
@@ -28,7 +28,7 @@ class FormatterFactoryTest extends TestCase | |||
28 | { | 28 | { |
29 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); | 29 | copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); |
30 | $this->conf = new ConfigManager(self::$testConf); | 30 | $this->conf = new ConfigManager(self::$testConf); |
31 | $this->factory = new FormatterFactory($this->conf); | 31 | $this->factory = new FormatterFactory($this->conf, true); |
32 | } | 32 | } |
33 | 33 | ||
34 | /** | 34 | /** |