aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2016-05-06 21:50:55 +0200
committerVirtualTam <virtualtam@flibidi.net>2016-05-06 21:50:55 +0200
commit00be05aaf5fc0238bbc27cec61341fc0fa0a8424 (patch)
treed4a484ca0eef729f5c02d95e0b20cc40e120853a /tests
parent6275a65969a84a360588e0a62b025963e9ec98e0 (diff)
parentbb4a23aa863b63e6148a085c15dedd7c960b4206 (diff)
downloadShaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.tar.gz
Shaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.tar.zst
Shaarli-00be05aaf5fc0238bbc27cec61341fc0fa0a8424.zip
Merge pull request #554 from virtualtam/fix/bookmark-export
Export: allow prepending notes with the Shaarli instance's URL
Diffstat (limited to 'tests')
-rw-r--r--tests/NetscapeBookmarkUtilsTest.php38
1 files changed, 34 insertions, 4 deletions
diff --git a/tests/NetscapeBookmarkUtilsTest.php b/tests/NetscapeBookmarkUtilsTest.php
index b7472d92..41e6d84c 100644
--- a/tests/NetscapeBookmarkUtilsTest.php
+++ b/tests/NetscapeBookmarkUtilsTest.php
@@ -39,7 +39,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase
39 */ 39 */
40 public function testFilterAndFormatInvalid() 40 public function testFilterAndFormatInvalid()
41 { 41 {
42 NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'derp'); 42 NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'derp', false, '');
43 } 43 }
44 44
45 /** 45 /**
@@ -47,7 +47,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase
47 */ 47 */
48 public function testFilterAndFormatAll() 48 public function testFilterAndFormatAll()
49 { 49 {
50 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all'); 50 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all', false, '');
51 $this->assertEquals(self::$refDb->countLinks(), sizeof($links)); 51 $this->assertEquals(self::$refDb->countLinks(), sizeof($links));
52 foreach ($links as $link) { 52 foreach ($links as $link) {
53 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 53 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@@ -67,7 +67,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase
67 */ 67 */
68 public function testFilterAndFormatPrivate() 68 public function testFilterAndFormatPrivate()
69 { 69 {
70 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private'); 70 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private', false, '');
71 $this->assertEquals(self::$refDb->countPrivateLinks(), sizeof($links)); 71 $this->assertEquals(self::$refDb->countPrivateLinks(), sizeof($links));
72 foreach ($links as $link) { 72 foreach ($links as $link) {
73 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 73 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@@ -87,7 +87,7 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase
87 */ 87 */
88 public function testFilterAndFormatPublic() 88 public function testFilterAndFormatPublic()
89 { 89 {
90 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public'); 90 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, '');
91 $this->assertEquals(self::$refDb->countPublicLinks(), sizeof($links)); 91 $this->assertEquals(self::$refDb->countPublicLinks(), sizeof($links));
92 foreach ($links as $link) { 92 foreach ($links as $link) {
93 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 93 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
@@ -101,4 +101,34 @@ class NetscapeBookmarkUtilsTest extends PHPUnit_Framework_TestCase
101 ); 101 );
102 } 102 }
103 } 103 }
104
105 /**
106 * Do not prepend notes with the Shaarli index's URL
107 */
108 public function testFilterAndFormatDoNotPrependNoteUrl()
109 {
110 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, '');
111 $this->assertEquals(
112 '?WDWyig',
113 $links[0]['url']
114 );
115 }
116
117 /**
118 * Prepend notes with the Shaarli index's URL
119 */
120 public function testFilterAndFormatPrependNoteUrl()
121 {
122 $indexUrl = 'http://localhost:7469/shaarli/';
123 $links = NetscapeBookmarkUtils::filterAndFormat(
124 self::$linkDb,
125 'public',
126 true,
127 $indexUrl
128 );
129 $this->assertEquals(
130 $indexUrl . '?WDWyig',
131 $links[0]['url']
132 );
133 }
104} 134}