X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fformatter%2FBookmarkDefaultFormatterTest.php;h=9534436e3f7e7150c19a50022be476a36754f6b2;hb=a5a9cf23acd1248585173aa32757d9720b5f2d62;hp=fe42a2087e7615b196a37defafd67c6fdf5035d4;hpb=e26e2060f5470ce8bf4c5973284bae07b8af170a;p=github%2Fshaarli%2FShaarli.git
diff --git a/tests/formatter/BookmarkDefaultFormatterTest.php b/tests/formatter/BookmarkDefaultFormatterTest.php
index fe42a208..9534436e 100644
--- a/tests/formatter/BookmarkDefaultFormatterTest.php
+++ b/tests/formatter/BookmarkDefaultFormatterTest.php
@@ -3,9 +3,9 @@
namespace Shaarli\Formatter;
use DateTime;
-use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\Bookmark;
use Shaarli\Config\ConfigManager;
+use Shaarli\TestCase;
/**
* Class BookmarkDefaultFormatterTest
@@ -25,11 +25,11 @@ class BookmarkDefaultFormatterTest extends TestCase
/**
* Initialize formatter instance.
*/
- public function setUp()
+ protected function setUp(): void
{
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf);
- $this->formatter = new BookmarkDefaultFormatter($this->conf);
+ $this->formatter = new BookmarkDefaultFormatter($this->conf, true);
}
/**
@@ -123,7 +123,7 @@ class BookmarkDefaultFormatterTest extends TestCase
$description[0] = 'This a <strong>description</strong>
';
$url = 'https://sub.domain.tld?query=here&for=real#hash';
$description[1] = 'text '. $url .' more text
';
- $description[2] = 'Also, there is an #hashtag added
';
$description[3] = ' A N D KEEP '.
'SPACES !
';
@@ -148,9 +148,30 @@ class BookmarkDefaultFormatterTest extends TestCase
$this->assertEquals($root . $short, $link['url']);
$this->assertEquals($root . $short, $link['real_url']);
$this->assertEquals(
- 'Text '.
+ 'Text '.
'#hashtag more text',
$link['description']
);
}
+
+ /**
+ * Make sure that private tags are properly filtered out when the user is logged out.
+ */
+ public function testFormatTagListRemovePrivate(): void
+ {
+ $this->formatter = new BookmarkDefaultFormatter($this->conf, false);
+
+ $bookmark = new Bookmark();
+ $bookmark->setId($id = 11);
+ $bookmark->setTags($tags = ['bookmark', '.private', 'othertag']);
+
+ $link = $this->formatter->format($bookmark);
+
+ unset($tags[1]);
+ $tags = array_values($tags);
+
+ $this->assertSame(11, $link['id']);
+ $this->assertSame($tags, $link['taglist']);
+ $this->assertSame(implode(' ', $tags), $link['tags']);
+ }
}