aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark/BookmarkFileServiceTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bookmark/BookmarkFileServiceTest.php')
-rw-r--r--tests/bookmark/BookmarkFileServiceTest.php33
1 files changed, 14 insertions, 19 deletions
diff --git a/tests/bookmark/BookmarkFileServiceTest.php b/tests/bookmark/BookmarkFileServiceTest.php
index 4900d41d..7b1906d3 100644
--- a/tests/bookmark/BookmarkFileServiceTest.php
+++ b/tests/bookmark/BookmarkFileServiceTest.php
@@ -200,7 +200,7 @@ class BookmarkFileServiceTest extends TestCase
200 200
201 $bookmark = $this->privateLinkDB->get(43); 201 $bookmark = $this->privateLinkDB->get(43);
202 $this->assertEquals(43, $bookmark->getId()); 202 $this->assertEquals(43, $bookmark->getId());
203 $this->assertRegExp('/\?[\w\-]{6}/', $bookmark->getUrl()); 203 $this->assertRegExp('#/shaare/[\w\-]{6}#', $bookmark->getUrl());
204 $this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl()); 204 $this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl());
205 $this->assertEquals($bookmark->getUrl(), $bookmark->getTitle()); 205 $this->assertEquals($bookmark->getUrl(), $bookmark->getTitle());
206 $this->assertEmpty($bookmark->getDescription()); 206 $this->assertEmpty($bookmark->getDescription());
@@ -216,7 +216,7 @@ class BookmarkFileServiceTest extends TestCase
216 216
217 $bookmark = $this->privateLinkDB->get(43); 217 $bookmark = $this->privateLinkDB->get(43);
218 $this->assertEquals(43, $bookmark->getId()); 218 $this->assertEquals(43, $bookmark->getId());
219 $this->assertRegExp('/\?[\w\-]{6}/', $bookmark->getUrl()); 219 $this->assertRegExp('#/shaare/[\w\-]{6}#', $bookmark->getUrl());
220 $this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl()); 220 $this->assertRegExp('/[\w\-]{6}/', $bookmark->getShortUrl());
221 $this->assertEquals($bookmark->getUrl(), $bookmark->getTitle()); 221 $this->assertEquals($bookmark->getUrl(), $bookmark->getTitle());
222 $this->assertEmpty($bookmark->getDescription()); 222 $this->assertEmpty($bookmark->getDescription());
@@ -340,7 +340,7 @@ class BookmarkFileServiceTest extends TestCase
340 340
341 $bookmark = $this->privateLinkDB->get(42); 341 $bookmark = $this->privateLinkDB->get(42);
342 $this->assertEquals(42, $bookmark->getId()); 342 $this->assertEquals(42, $bookmark->getId());
343 $this->assertEquals('?WDWyig', $bookmark->getUrl()); 343 $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
344 $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); 344 $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
345 $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); 345 $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
346 $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); 346 $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
@@ -359,7 +359,7 @@ class BookmarkFileServiceTest extends TestCase
359 359
360 $bookmark = $this->privateLinkDB->get(42); 360 $bookmark = $this->privateLinkDB->get(42);
361 $this->assertEquals(42, $bookmark->getId()); 361 $this->assertEquals(42, $bookmark->getId());
362 $this->assertEquals('?WDWyig', $bookmark->getUrl()); 362 $this->assertEquals('/shaare/WDWyig', $bookmark->getUrl());
363 $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl()); 363 $this->assertEquals('1eYJ1Q', $bookmark->getShortUrl());
364 $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle()); 364 $this->assertEquals('Note: I have a big ID but an old date', $bookmark->getTitle());
365 $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription()); 365 $this->assertEquals('Used to test bookmarks reordering.', $bookmark->getDescription());
@@ -816,7 +816,6 @@ class BookmarkFileServiceTest extends TestCase
816 ); 816 );
817 $this->assertEquals( 817 $this->assertEquals(
818 [ 818 [
819 'web' => 4,
820 'cartoon' => 2, 819 'cartoon' => 2,
821 'gnu' => 1, 820 'gnu' => 1,
822 'dev' => 1, 821 'dev' => 1,
@@ -833,7 +832,6 @@ class BookmarkFileServiceTest extends TestCase
833 ); 832 );
834 $this->assertEquals( 833 $this->assertEquals(
835 [ 834 [
836 'web' => 1,
837 'html' => 1, 835 'html' => 1,
838 'w3c' => 1, 836 'w3c' => 1,
839 'css' => 1, 837 'css' => 1,
@@ -894,35 +892,35 @@ class BookmarkFileServiceTest extends TestCase
894 public function testFilterHashValid() 892 public function testFilterHashValid()
895 { 893 {
896 $request = smallHash('20150310_114651'); 894 $request = smallHash('20150310_114651');
897 $this->assertEquals( 895 $this->assertSame(
898 1, 896 $request,
899 count($this->publicLinkDB->findByHash($request)) 897 $this->publicLinkDB->findByHash($request)->getShortUrl()
900 ); 898 );
901 $request = smallHash('20150310_114633' . 8); 899 $request = smallHash('20150310_114633' . 8);
902 $this->assertEquals( 900 $this->assertSame(
903 1, 901 $request,
904 count($this->publicLinkDB->findByHash($request)) 902 $this->publicLinkDB->findByHash($request)->getShortUrl()
905 ); 903 );
906 } 904 }
907 905
908 /** 906 /**
909 * Test filterHash() with an invalid smallhash. 907 * Test filterHash() with an invalid smallhash.
910 *
911 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
912 */ 908 */
913 public function testFilterHashInValid1() 909 public function testFilterHashInValid1()
914 { 910 {
911 $this->expectException(BookmarkNotFoundException::class);
912
915 $request = 'blabla'; 913 $request = 'blabla';
916 $this->publicLinkDB->findByHash($request); 914 $this->publicLinkDB->findByHash($request);
917 } 915 }
918 916
919 /** 917 /**
920 * Test filterHash() with an empty smallhash. 918 * Test filterHash() with an empty smallhash.
921 *
922 * @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
923 */ 919 */
924 public function testFilterHashInValid() 920 public function testFilterHashInValid()
925 { 921 {
922 $this->expectException(BookmarkNotFoundException::class);
923
926 $this->publicLinkDB->findByHash(''); 924 $this->publicLinkDB->findByHash('');
927 } 925 }
928 926
@@ -968,7 +966,6 @@ class BookmarkFileServiceTest extends TestCase
968 public function testCountLinkPerTagAllWithFilter() 966 public function testCountLinkPerTagAllWithFilter()
969 { 967 {
970 $expected = [ 968 $expected = [
971 'gnu' => 2,
972 'hashtag' => 2, 969 'hashtag' => 2,
973 '-exclude' => 1, 970 '-exclude' => 1,
974 '.hidden' => 1, 971 '.hidden' => 1,
@@ -991,7 +988,6 @@ class BookmarkFileServiceTest extends TestCase
991 public function testCountLinkPerTagPublicWithFilter() 988 public function testCountLinkPerTagPublicWithFilter()
992 { 989 {
993 $expected = [ 990 $expected = [
994 'gnu' => 2,
995 'hashtag' => 2, 991 'hashtag' => 2,
996 '-exclude' => 1, 992 '-exclude' => 1,
997 '.hidden' => 1, 993 '.hidden' => 1,
@@ -1015,7 +1011,6 @@ class BookmarkFileServiceTest extends TestCase
1015 { 1011 {
1016 $expected = [ 1012 $expected = [
1017 'cartoon' => 1, 1013 'cartoon' => 1,
1018 'dev' => 1,
1019 'tag1' => 1, 1014 'tag1' => 1,
1020 'tag2' => 1, 1015 'tag2' => 1,
1021 'tag3' => 1, 1016 'tag3' => 1,