From 03340c18ead651ef9e11f883745695f2edafbae3 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 12 May 2020 12:44:48 +0200 Subject: Slim router: handle add tag route --- tests/bookmark/LinkUtilsTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/LinkUtilsTest.php b/tests/bookmark/LinkUtilsTest.php index 591976f2..7d4a7b89 100644 --- a/tests/bookmark/LinkUtilsTest.php +++ b/tests/bookmark/LinkUtilsTest.php @@ -3,8 +3,6 @@ namespace Shaarli\Bookmark; use PHPUnit\Framework\TestCase; -use ReferenceLinkDB; -use Shaarli\Config\ConfigManager; require_once 'tests/utils/CurlUtils.php'; @@ -491,7 +489,7 @@ class LinkUtilsTest extends TestCase */ private function getHashtagLink($hashtag, $index = '') { - $hashtagLink = '#$1'; + $hashtagLink = '#$1'; return str_replace('$1', $hashtag, $hashtagLink); } } -- cgit v1.2.3 From c79473bd84ab5aba7836d2caaf61847cabaf1e53 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 16 May 2020 13:13:00 +0200 Subject: Handle tag filtering in the Bookmark service --- tests/bookmark/BookmarkFileServiceTest.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index 4900d41d..5adc26aa 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -816,7 +816,6 @@ class BookmarkFileServiceTest extends TestCase ); $this->assertEquals( [ - 'web' => 4, 'cartoon' => 2, 'gnu' => 1, 'dev' => 1, @@ -833,7 +832,6 @@ class BookmarkFileServiceTest extends TestCase ); $this->assertEquals( [ - 'web' => 1, 'html' => 1, 'w3c' => 1, 'css' => 1, @@ -968,7 +966,6 @@ class BookmarkFileServiceTest extends TestCase public function testCountLinkPerTagAllWithFilter() { $expected = [ - 'gnu' => 2, 'hashtag' => 2, '-exclude' => 1, '.hidden' => 1, @@ -991,7 +988,6 @@ class BookmarkFileServiceTest extends TestCase public function testCountLinkPerTagPublicWithFilter() { $expected = [ - 'gnu' => 2, 'hashtag' => 2, '-exclude' => 1, '.hidden' => 1, @@ -1015,7 +1011,6 @@ class BookmarkFileServiceTest extends TestCase { $expected = [ 'cartoon' => 1, - 'dev' => 1, 'tag1' => 1, 'tag2' => 1, 'tag3' => 1, -- cgit v1.2.3 From 1a8ac737e52cb25a5c346232ee398f5908cee7d7 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 6 Jul 2020 08:04:35 +0200 Subject: Process main page (linklist) through Slim controller Including a bunch of improvements on the container, and helper used across new controllers. --- tests/bookmark/BookmarkFileServiceTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index 5adc26aa..b19c8250 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -892,35 +892,35 @@ class BookmarkFileServiceTest extends TestCase 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(''); } -- cgit v1.2.3 From 301c7ab1a079d937ab41c6f52b8804e5731008e6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 28 Jul 2020 20:46:11 +0200 Subject: Better support for notes permalink --- tests/bookmark/BookmarkFileServiceTest.php | 4 ++-- tests/bookmark/BookmarkTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index b19c8250..a8bf47cb 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -200,7 +200,7 @@ class BookmarkFileServiceTest extends TestCase $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()); @@ -216,7 +216,7 @@ class BookmarkFileServiceTest extends TestCase $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()); diff --git a/tests/bookmark/BookmarkTest.php b/tests/bookmark/BookmarkTest.php index 9a3bbbfc..4b6a3c07 100644 --- a/tests/bookmark/BookmarkTest.php +++ b/tests/bookmark/BookmarkTest.php @@ -124,8 +124,8 @@ class BookmarkTest extends TestCase $this->assertEquals(1, $bookmark->getId()); $this->assertEquals('abc', $bookmark->getShortUrl()); $this->assertEquals($date, $bookmark->getCreated()); - $this->assertEquals('?abc', $bookmark->getUrl()); - $this->assertEquals('?abc', $bookmark->getTitle()); + $this->assertEquals('/shaare/abc', $bookmark->getUrl()); + $this->assertEquals('/shaare/abc', $bookmark->getTitle()); $this->assertEquals('', $bookmark->getDescription()); $this->assertEquals([], $bookmark->getTags()); $this->assertEquals('', $bookmark->getTagsString()); -- cgit v1.2.3 From f7f08ceec1b218e1525153e8bd3d0199f2fb1c9d Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 28 Jul 2020 22:24:41 +0200 Subject: Fix basePath in unit tests reference DB --- tests/bookmark/BookmarkFileServiceTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php index a8bf47cb..7b1906d3 100644 --- a/tests/bookmark/BookmarkFileServiceTest.php +++ b/tests/bookmark/BookmarkFileServiceTest.php @@ -340,7 +340,7 @@ class BookmarkFileServiceTest extends TestCase $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()); @@ -359,7 +359,7 @@ class BookmarkFileServiceTest extends TestCase $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()); -- cgit v1.2.3 From d6e5f04d3987e498c5cb859eed6bff33d67949df Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 1 Aug 2020 11:10:57 +0200 Subject: Remove anonymous permission and initialize bookmarks on login --- tests/bookmark/BookmarkInitializerTest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/bookmark') diff --git a/tests/bookmark/BookmarkInitializerTest.php b/tests/bookmark/BookmarkInitializerTest.php index d23eb069..3906cc7f 100644 --- a/tests/bookmark/BookmarkInitializerTest.php +++ b/tests/bookmark/BookmarkInitializerTest.php @@ -3,7 +3,6 @@ namespace Shaarli\Bookmark; use PHPUnit\Framework\TestCase; -use ReferenceLinkDB; use Shaarli\Config\ConfigManager; use Shaarli\History; @@ -54,9 +53,9 @@ class BookmarkInitializerTest extends TestCase } /** - * Test initialize() with an empty data store. + * Test initialize() with a data store containing bookmarks. */ - public function testInitializeEmptyDataStore() + public function testInitializeNotEmptyDataStore(): void { $refDB = new \ReferenceLinkDB(); $refDB->write(self::$testDatastore); @@ -79,6 +78,8 @@ class BookmarkInitializerTest extends TestCase ); $this->assertFalse($bookmark->isPrivate()); + $this->bookmarkService->save(); + // Reload from file $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); $this->assertEquals($refDB->countLinks() + 2, $this->bookmarkService->count()); @@ -97,10 +98,13 @@ class BookmarkInitializerTest extends TestCase } /** - * Test initialize() with a data store containing bookmarks. + * Test initialize() with an a non existent datastore file . */ - public function testInitializeNotEmptyDataStore() + public function testInitializeNonExistentDataStore(): void { + $this->conf->set('resource.datastore', static::$testDatastore . '_empty'); + $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); + $this->initializer->initialize(); $this->assertEquals(2, $this->bookmarkService->count()); -- cgit v1.2.3