use Shaarli;
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
use Shaarli\Config\ConfigManager;
+use Shaarli\Formatter\BookmarkMarkdownFormatter;
use Shaarli\History;
/**
$bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId());
- $this->assertRegExp('/\?[\w\-]{6}/', $bookmark->getUrl());
+ $this->assertRegExp('#/shaare/[\w\-]{6}#', $bookmark->getUrl());
$this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl());
$this->assertEquals($bookmark->getUrl(), $bookmark->getTitle());
$this->assertEmpty($bookmark->getDescription());
$bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId());
- $this->assertRegExp('/\?[\w\-]{6}/', $bookmark->getUrl());
+ $this->assertRegExp('#/shaare/[\w\-]{6}#', $bookmark->getUrl());
$this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl());
$this->assertEquals($bookmark->getUrl(), $bookmark->getTitle());
$this->assertEmpty($bookmark->getDescription());
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
- $this->assertEquals('?WDWyig', $bookmark->getUrl());
+ $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
$this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
$this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
$this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
$bookmark = $this->privateLinkDB->get(42);
$this->assertEquals(42, $bookmark->getId());
- $this->assertEquals('?WDWyig', $bookmark->getUrl());
+ $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
$this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
$this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
$this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
);
$this->assertEquals(
[
- 'web' => 4,
'cartoon' => 2,
'gnu' => 1,
'dev' => 1,
);
$this->assertEquals(
[
- 'web' => 1,
'html' => 1,
'w3c' => 1,
'css' => 1,
public function testFilterHashValid()
{
$request = smallHash('20150310_114651');
- $this->assertEquals(
- 1,
- count($this->publicLinkDB->findByHash($request))
+ $this->assertSame(
+ $request,
+ $this->publicLinkDB->findByHash($request)->getShortUrl()
);
$request = smallHash('20150310_114633' . 8);
- $this->assertEquals(
- 1,
- count($this->publicLinkDB->findByHash($request))
+ $this->assertSame(
+ $request,
+ $this->publicLinkDB->findByHash($request)->getShortUrl()
);
}
/**
* Test filterHash() with an invalid smallhash.
- *
- * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/
public function testFilterHashInValid1()
{
+ $this->expectException(BookmarkNotFoundException::class);
+
$request = 'blabla';
$this->publicLinkDB->findByHash($request);
}
/**
* Test filterHash() with an empty smallhash.
- *
- * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/
public function testFilterHashInValid()
{
+ $this->expectException(BookmarkNotFoundException::class);
+
$this->publicLinkDB->findByHash('');
}
public function testCountLinkPerTagAllWithFilter()
{
$expected = [
- 'gnu' => 2,
'hashtag' => 2,
'-exclude' => 1,
'.hidden' => 1,
public function testCountLinkPerTagPublicWithFilter()
{
$expected = [
- 'gnu' => 2,
'hashtag' => 2,
'-exclude' => 1,
'.hidden' => 1,
{
$expected = [
'cartoon' => 1,
- 'dev' => 1,
'tag1' => 1,
'tag2' => 1,
'tag3' => 1,
$this->assertEquals($expected, $tags, var_export($tags, true));
}
+ /**
+ * Test linksCountPerTag public tags with filter.
+ * Equal occurrences should be sorted alphabetically.
+ */
+ public function testCountTagsNoMarkdown()
+ {
+ $expected = [
+ 'cartoon' => 3,
+ 'dev' => 2,
+ 'tag1' => 1,
+ 'tag2' => 1,
+ 'tag3' => 1,
+ 'tag4' => 1,
+ 'web' => 4,
+ 'gnu' => 2,
+ 'hashtag' => 2,
+ 'sTuff' => 2,
+ '-exclude' => 1,
+ '.hidden' => 1,
+ 'Mercurial' => 1,
+ 'css' => 1,
+ 'free' => 1,
+ 'html' => 1,
+ 'media' => 1,
+ 'newTagToCount' => 1,
+ 'samba' => 1,
+ 'software' => 1,
+ 'stallman' => 1,
+ 'ut' => 1,
+ 'w3c' => 1,
+ ];
+ $bookmark = new Bookmark();
+ $bookmark->setTags(['newTagToCount', BookmarkMarkdownFormatter::NO_MD_TAG]);
+ $this->privateLinkDB->add($bookmark);
+
+ $tags = $this->privateLinkDB->bookmarksCountPerTag();
+
+ $this->assertEquals($expected, $tags, var_export($tags, true));
+ }
+
/**
* Allows to test LinkDB's private methods
*