aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-04 00:13:42 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 23:11:19 +0100
commit349b0144011e25f2b1a727b1d28d49d55b3b2ebb (patch)
tree99cf1746e597672389afc1b9231afa16df65de5a /tests/NetscapeBookmarkUtils/BookmarkExportTest.php
parenta932f486f20f3daf8ad657d8d39a6d6c316e66eb (diff)
downloadShaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.tar.gz
Shaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.tar.zst
Shaarli-349b0144011e25f2b1a727b1d28d49d55b3b2ebb.zip
namespacing: \Shaarli\Netscape\NetscapeBookmarkUtils
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests/NetscapeBookmarkUtils/BookmarkExportTest.php')
-rw-r--r--tests/NetscapeBookmarkUtils/BookmarkExportTest.php136
1 files changed, 0 insertions, 136 deletions
diff --git a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php b/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
deleted file mode 100644
index adf854c5..00000000
--- a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
1<?php
2
3use Shaarli\Bookmark\LinkDB;
4
5require_once 'application/NetscapeBookmarkUtils.php';
6
7/**
8 * Netscape bookmark export
9 */
10class BookmarkExportTest extends PHPUnit_Framework_TestCase
11{
12 /**
13 * @var string datastore to test write operations
14 */
15 protected static $testDatastore = 'sandbox/datastore.php';
16
17 /**
18 * @var ReferenceLinkDB instance.
19 */
20 protected static $refDb = null;
21
22 /**
23 * @var LinkDB private LinkDB instance.
24 */
25 protected static $linkDb = null;
26
27 /**
28 * Instantiate reference data
29 */
30 public static function setUpBeforeClass()
31 {
32 self::$refDb = new ReferenceLinkDB();
33 self::$refDb->write(self::$testDatastore);
34 self::$linkDb = new LinkDB(self::$testDatastore, true, false);
35 }
36
37 /**
38 * Attempt to export an invalid link selection
39 * @expectedException Exception
40 * @expectedExceptionMessageRegExp /Invalid export selection/
41 */
42 public function testFilterAndFormatInvalid()
43 {
44 NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'derp', false, '');
45 }
46
47 /**
48 * Prepare all links for export
49 */
50 public function testFilterAndFormatAll()
51 {
52 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all', false, '');
53 $this->assertEquals(self::$refDb->countLinks(), sizeof($links));
54 foreach ($links as $link) {
55 $date = $link['created'];
56 $this->assertEquals(
57 $date->getTimestamp(),
58 $link['timestamp']
59 );
60 $this->assertEquals(
61 str_replace(' ', ',', $link['tags']),
62 $link['taglist']
63 );
64 }
65 }
66
67 /**
68 * Prepare private links for export
69 */
70 public function testFilterAndFormatPrivate()
71 {
72 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private', false, '');
73 $this->assertEquals(self::$refDb->countPrivateLinks(), sizeof($links));
74 foreach ($links as $link) {
75 $date = $link['created'];
76 $this->assertEquals(
77 $date->getTimestamp(),
78 $link['timestamp']
79 );
80 $this->assertEquals(
81 str_replace(' ', ',', $link['tags']),
82 $link['taglist']
83 );
84 }
85 }
86
87 /**
88 * Prepare public links for export
89 */
90 public function testFilterAndFormatPublic()
91 {
92 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, '');
93 $this->assertEquals(self::$refDb->countPublicLinks(), sizeof($links));
94 foreach ($links as $link) {
95 $date = $link['created'];
96 $this->assertEquals(
97 $date->getTimestamp(),
98 $link['timestamp']
99 );
100 $this->assertEquals(
101 str_replace(' ', ',', $link['tags']),
102 $link['taglist']
103 );
104 }
105 }
106
107 /**
108 * Do not prepend notes with the Shaarli index's URL
109 */
110 public function testFilterAndFormatDoNotPrependNoteUrl()
111 {
112 $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, '');
113 $this->assertEquals(
114 '?WDWyig',
115 $links[2]['url']
116 );
117 }
118
119 /**
120 * Prepend notes with the Shaarli index's URL
121 */
122 public function testFilterAndFormatPrependNoteUrl()
123 {
124 $indexUrl = 'http://localhost:7469/shaarli/';
125 $links = NetscapeBookmarkUtils::filterAndFormat(
126 self::$linkDb,
127 'public',
128 true,
129 $indexUrl
130 );
131 $this->assertEquals(
132 $indexUrl . '?WDWyig',
133 $links[2]['url']
134 );
135 }
136}