diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-11-28 16:17:25 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-12-12 03:03:12 +0100 |
commit | c3dfd8995921083ff7250c25d0b6ab1184b91aff (patch) | |
tree | cb7cb17ad607a5bd2e7d9ee59c0e804e590fa6af /tests/NetscapeBookmarkUtils | |
parent | 01878a75b93b9966f7366ea2937c118bbc3e459e (diff) | |
download | Shaarli-c3dfd8995921083ff7250c25d0b6ab1184b91aff.tar.gz Shaarli-c3dfd8995921083ff7250c25d0b6ab1184b91aff.tar.zst Shaarli-c3dfd8995921083ff7250c25d0b6ab1184b91aff.zip |
Unit Test for the new ID system
Diffstat (limited to 'tests/NetscapeBookmarkUtils')
-rw-r--r-- | tests/NetscapeBookmarkUtils/BookmarkExportTest.php | 6 | ||||
-rw-r--r-- | tests/NetscapeBookmarkUtils/BookmarkImportTest.php | 146 |
2 files changed, 98 insertions, 54 deletions
diff --git a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php b/tests/NetscapeBookmarkUtils/BookmarkExportTest.php index cc54ab9f..6a47bbb9 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php +++ b/tests/NetscapeBookmarkUtils/BookmarkExportTest.php | |||
@@ -50,7 +50,7 @@ class BookmarkExportTest extends PHPUnit_Framework_TestCase | |||
50 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'all', false, ''); | 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 = $link['created']; |
54 | $this->assertEquals( | 54 | $this->assertEquals( |
55 | $date->getTimestamp(), | 55 | $date->getTimestamp(), |
56 | $link['timestamp'] | 56 | $link['timestamp'] |
@@ -70,7 +70,7 @@ class BookmarkExportTest extends PHPUnit_Framework_TestCase | |||
70 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'private', false, ''); | 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 = $link['created']; |
74 | $this->assertEquals( | 74 | $this->assertEquals( |
75 | $date->getTimestamp(), | 75 | $date->getTimestamp(), |
76 | $link['timestamp'] | 76 | $link['timestamp'] |
@@ -90,7 +90,7 @@ class BookmarkExportTest extends PHPUnit_Framework_TestCase | |||
90 | $links = NetscapeBookmarkUtils::filterAndFormat(self::$linkDb, 'public', false, ''); | 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 = $link['created']; |
94 | $this->assertEquals( | 94 | $this->assertEquals( |
95 | $date->getTimestamp(), | 95 | $date->getTimestamp(), |
96 | $link['timestamp'] | 96 | $link['timestamp'] |
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php index f0ad500f..96895b00 100644 --- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php +++ b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php | |||
@@ -43,6 +43,18 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
43 | protected $pagecache = 'tests'; | 43 | protected $pagecache = 'tests'; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * @var string Save the current timezone. | ||
47 | */ | ||
48 | protected static $defaultTimeZone; | ||
49 | |||
50 | public static function setUpBeforeClass() | ||
51 | { | ||
52 | self::$defaultTimeZone = date_default_timezone_get(); | ||
53 | // Timezone without DST for test consistency | ||
54 | date_default_timezone_set('Africa/Nairobi'); | ||
55 | } | ||
56 | |||
57 | /** | ||
46 | * Resets test data before each test | 58 | * Resets test data before each test |
47 | */ | 59 | */ |
48 | protected function setUp() | 60 | protected function setUp() |
@@ -55,6 +67,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
55 | $this->linkDb = new LinkDB(self::$testDatastore, true, false); | 67 | $this->linkDb = new LinkDB(self::$testDatastore, true, false); |
56 | } | 68 | } |
57 | 69 | ||
70 | public static function tearDownAfterClass() | ||
71 | { | ||
72 | date_default_timezone_set(self::$defaultTimeZone); | ||
73 | } | ||
74 | |||
58 | /** | 75 | /** |
59 | * Attempt to import bookmarks from an empty file | 76 | * Attempt to import bookmarks from an empty file |
60 | */ | 77 | */ |
@@ -98,18 +115,19 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
98 | 115 | ||
99 | $this->assertEquals( | 116 | $this->assertEquals( |
100 | array( | 117 | array( |
101 | 'linkdate' => '20160618_173944', | 118 | 'id' => 0, |
119 | 'created' => DateTime::createFromFormat('Ymd_His', '20160618_203944'), | ||
102 | 'title' => 'Hg Init a Mercurial tutorial by Joel Spolsky', | 120 | 'title' => 'Hg Init a Mercurial tutorial by Joel Spolsky', |
103 | 'url' => 'http://hginit.com/', | 121 | 'url' => 'http://hginit.com/', |
104 | 'description' => '', | 122 | 'description' => '', |
105 | 'private' => 0, | 123 | 'private' => 0, |
106 | 'tags' => '' | 124 | 'tags' => '', |
125 | 'shorturl' => 'La37cg', | ||
107 | ), | 126 | ), |
108 | $this->linkDb->getLinkFromUrl('http://hginit.com/') | 127 | $this->linkDb->getLinkFromUrl('http://hginit.com/') |
109 | ); | 128 | ); |
110 | } | 129 | } |
111 | 130 | ||
112 | |||
113 | /** | 131 | /** |
114 | * Import bookmarks nested in a folder hierarchy | 132 | * Import bookmarks nested in a folder hierarchy |
115 | */ | 133 | */ |
@@ -126,89 +144,105 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
126 | 144 | ||
127 | $this->assertEquals( | 145 | $this->assertEquals( |
128 | array( | 146 | array( |
129 | 'linkdate' => '20160225_205541', | 147 | 'id' => 0, |
148 | 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235541'), | ||
130 | 'title' => 'Nested 1', | 149 | 'title' => 'Nested 1', |
131 | 'url' => 'http://nest.ed/1', | 150 | 'url' => 'http://nest.ed/1', |
132 | 'description' => '', | 151 | 'description' => '', |
133 | 'private' => 0, | 152 | 'private' => 0, |
134 | 'tags' => 'tag1 tag2' | 153 | 'tags' => 'tag1 tag2', |
154 | 'shorturl' => 'KyDNKA', | ||
135 | ), | 155 | ), |
136 | $this->linkDb->getLinkFromUrl('http://nest.ed/1') | 156 | $this->linkDb->getLinkFromUrl('http://nest.ed/1') |
137 | ); | 157 | ); |
138 | $this->assertEquals( | 158 | $this->assertEquals( |
139 | array( | 159 | array( |
140 | 'linkdate' => '20160225_205542', | 160 | 'id' => 1, |
161 | 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235542'), | ||
141 | 'title' => 'Nested 1-1', | 162 | 'title' => 'Nested 1-1', |
142 | 'url' => 'http://nest.ed/1-1', | 163 | 'url' => 'http://nest.ed/1-1', |
143 | 'description' => '', | 164 | 'description' => '', |
144 | 'private' => 0, | 165 | 'private' => 0, |
145 | 'tags' => 'folder1 tag1 tag2' | 166 | 'tags' => 'folder1 tag1 tag2', |
167 | 'shorturl' => 'T2LnXg', | ||
146 | ), | 168 | ), |
147 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-1') | 169 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-1') |
148 | ); | 170 | ); |
149 | $this->assertEquals( | 171 | $this->assertEquals( |
150 | array( | 172 | array( |
151 | 'linkdate' => '20160225_205547', | 173 | 'id' => 2, |
174 | 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235547'), | ||
152 | 'title' => 'Nested 1-2', | 175 | 'title' => 'Nested 1-2', |
153 | 'url' => 'http://nest.ed/1-2', | 176 | 'url' => 'http://nest.ed/1-2', |
154 | 'description' => '', | 177 | 'description' => '', |
155 | 'private' => 0, | 178 | 'private' => 0, |
156 | 'tags' => 'folder1 tag3 tag4' | 179 | 'tags' => 'folder1 tag3 tag4', |
180 | 'shorturl' => '46SZxA', | ||
157 | ), | 181 | ), |
158 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-2') | 182 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-2') |
159 | ); | 183 | ); |
160 | $this->assertEquals( | 184 | $this->assertEquals( |
161 | array( | 185 | array( |
162 | 'linkdate' => '20160202_172222', | 186 | 'id' => 3, |
187 | 'created' => DateTime::createFromFormat('Ymd_His', '20160202_202222'), | ||
163 | 'title' => 'Nested 2-1', | 188 | 'title' => 'Nested 2-1', |
164 | 'url' => 'http://nest.ed/2-1', | 189 | 'url' => 'http://nest.ed/2-1', |
165 | 'description' => 'First link of the second section', | 190 | 'description' => 'First link of the second section', |
166 | 'private' => 1, | 191 | 'private' => 1, |
167 | 'tags' => 'folder2' | 192 | 'tags' => 'folder2', |
193 | 'shorturl' => '4UHOSw', | ||
168 | ), | 194 | ), |
169 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-1') | 195 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-1') |
170 | ); | 196 | ); |
171 | $this->assertEquals( | 197 | $this->assertEquals( |
172 | array( | 198 | array( |
173 | 'linkdate' => '20160119_200227', | 199 | 'id' => 4, |
200 | 'created' => DateTime::createFromFormat('Ymd_His', '20160119_230227'), | ||
174 | 'title' => 'Nested 2-2', | 201 | 'title' => 'Nested 2-2', |
175 | 'url' => 'http://nest.ed/2-2', | 202 | 'url' => 'http://nest.ed/2-2', |
176 | 'description' => 'Second link of the second section', | 203 | 'description' => 'Second link of the second section', |
177 | 'private' => 1, | 204 | 'private' => 1, |
178 | 'tags' => 'folder2' | 205 | 'tags' => 'folder2', |
206 | 'shorturl' => 'yfzwbw', | ||
179 | ), | 207 | ), |
180 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-2') | 208 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-2') |
181 | ); | 209 | ); |
182 | $this->assertEquals( | 210 | $this->assertEquals( |
183 | array( | 211 | array( |
184 | 'linkdate' => '20160202_172223', | 212 | 'id' => 5, |
213 | 'created' => DateTime::createFromFormat('Ymd_His', '20160202_202222'), | ||
185 | 'title' => 'Nested 3-1', | 214 | 'title' => 'Nested 3-1', |
186 | 'url' => 'http://nest.ed/3-1', | 215 | 'url' => 'http://nest.ed/3-1', |
187 | 'description' => '', | 216 | 'description' => '', |
188 | 'private' => 0, | 217 | 'private' => 0, |
189 | 'tags' => 'folder3 folder3-1 tag3' | 218 | 'tags' => 'folder3 folder3-1 tag3', |
219 | 'shorturl' => 'UwxIUQ', | ||
190 | ), | 220 | ), |
191 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-1') | 221 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-1') |
192 | ); | 222 | ); |
193 | $this->assertEquals( | 223 | $this->assertEquals( |
194 | array( | 224 | array( |
195 | 'linkdate' => '20160119_200228', | 225 | 'id' => 6, |
226 | 'created' => DateTime::createFromFormat('Ymd_His', '20160119_230227'), | ||
196 | 'title' => 'Nested 3-2', | 227 | 'title' => 'Nested 3-2', |
197 | 'url' => 'http://nest.ed/3-2', | 228 | 'url' => 'http://nest.ed/3-2', |
198 | 'description' => '', | 229 | 'description' => '', |
199 | 'private' => 0, | 230 | 'private' => 0, |
200 | 'tags' => 'folder3 folder3-1' | 231 | 'tags' => 'folder3 folder3-1', |
232 | 'shorturl' => 'p8dyZg', | ||
201 | ), | 233 | ), |
202 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-2') | 234 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-2') |
203 | ); | 235 | ); |
204 | $this->assertEquals( | 236 | $this->assertEquals( |
205 | array( | 237 | array( |
206 | 'linkdate' => '20160229_081541', | 238 | 'id' => 7, |
239 | 'created' => DateTime::createFromFormat('Ymd_His', '20160229_111541'), | ||
207 | 'title' => 'Nested 2', | 240 | 'title' => 'Nested 2', |
208 | 'url' => 'http://nest.ed/2', | 241 | 'url' => 'http://nest.ed/2', |
209 | 'description' => '', | 242 | 'description' => '', |
210 | 'private' => 0, | 243 | 'private' => 0, |
211 | 'tags' => 'tag4' | 244 | 'tags' => 'tag4', |
245 | 'shorturl' => 'Gt3Uug', | ||
212 | ), | 246 | ), |
213 | $this->linkDb->getLinkFromUrl('http://nest.ed/2') | 247 | $this->linkDb->getLinkFromUrl('http://nest.ed/2') |
214 | ); | 248 | ); |
@@ -227,28 +261,34 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
227 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | 261 | .' 2 links imported, 0 links overwritten, 0 links skipped.', |
228 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) | 262 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->pagecache) |
229 | ); | 263 | ); |
264 | |||
230 | $this->assertEquals(2, count($this->linkDb)); | 265 | $this->assertEquals(2, count($this->linkDb)); |
231 | $this->assertEquals(1, count_private($this->linkDb)); | 266 | $this->assertEquals(1, count_private($this->linkDb)); |
232 | 267 | ||
233 | $this->assertEquals( | 268 | $this->assertEquals( |
234 | array( | 269 | array( |
235 | 'linkdate' => '20001010_105536', | 270 | 'id' => 0, |
271 | // Old link - UTC+4 (note that TZ in the import file is ignored). | ||
272 | 'created' => DateTime::createFromFormat('Ymd_His', '20001010_135536'), | ||
236 | 'title' => 'Secret stuff', | 273 | 'title' => 'Secret stuff', |
237 | 'url' => 'https://private.tld', | 274 | 'url' => 'https://private.tld', |
238 | 'description' => "Super-secret stuff you're not supposed to know about", | 275 | 'description' => "Super-secret stuff you're not supposed to know about", |
239 | 'private' => 1, | 276 | 'private' => 1, |
240 | 'tags' => 'private secret' | 277 | 'tags' => 'private secret', |
278 | 'shorturl' => 'EokDtA', | ||
241 | ), | 279 | ), |
242 | $this->linkDb->getLinkFromUrl('https://private.tld') | 280 | $this->linkDb->getLinkFromUrl('https://private.tld') |
243 | ); | 281 | ); |
244 | $this->assertEquals( | 282 | $this->assertEquals( |
245 | array( | 283 | array( |
246 | 'linkdate' => '20160225_205548', | 284 | 'id' => 1, |
285 | 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235548'), | ||
247 | 'title' => 'Public stuff', | 286 | 'title' => 'Public stuff', |
248 | 'url' => 'http://public.tld', | 287 | 'url' => 'http://public.tld', |
249 | 'description' => '', | 288 | 'description' => '', |
250 | 'private' => 0, | 289 | 'private' => 0, |
251 | 'tags' => 'public hello world' | 290 | 'tags' => 'public hello world', |
291 | 'shorturl' => 'Er9ddA', | ||
252 | ), | 292 | ), |
253 | $this->linkDb->getLinkFromUrl('http://public.tld') | 293 | $this->linkDb->getLinkFromUrl('http://public.tld') |
254 | ); | 294 | ); |
@@ -271,23 +311,28 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
271 | 311 | ||
272 | $this->assertEquals( | 312 | $this->assertEquals( |
273 | array( | 313 | array( |
274 | 'linkdate' => '20001010_105536', | 314 | 'id' => 0, |
315 | // Note that TZ in the import file is ignored. | ||
316 | 'created' => DateTime::createFromFormat('Ymd_His', '20001010_135536'), | ||
275 | 'title' => 'Secret stuff', | 317 | 'title' => 'Secret stuff', |
276 | 'url' => 'https://private.tld', | 318 | 'url' => 'https://private.tld', |
277 | 'description' => "Super-secret stuff you're not supposed to know about", | 319 | 'description' => "Super-secret stuff you're not supposed to know about", |
278 | 'private' => 1, | 320 | 'private' => 1, |
279 | 'tags' => 'private secret' | 321 | 'tags' => 'private secret', |
322 | 'shorturl' => 'EokDtA', | ||
280 | ), | 323 | ), |
281 | $this->linkDb->getLinkFromUrl('https://private.tld') | 324 | $this->linkDb->getLinkFromUrl('https://private.tld') |
282 | ); | 325 | ); |
283 | $this->assertEquals( | 326 | $this->assertEquals( |
284 | array( | 327 | array( |
285 | 'linkdate' => '20160225_205548', | 328 | 'id' => 1, |
329 | 'created' => DateTime::createFromFormat('Ymd_His', '20160225_235548'), | ||
286 | 'title' => 'Public stuff', | 330 | 'title' => 'Public stuff', |
287 | 'url' => 'http://public.tld', | 331 | 'url' => 'http://public.tld', |
288 | 'description' => '', | 332 | 'description' => '', |
289 | 'private' => 0, | 333 | 'private' => 0, |
290 | 'tags' => 'public hello world' | 334 | 'tags' => 'public hello world', |
335 | 'shorturl' => 'Er9ddA', | ||
291 | ), | 336 | ), |
292 | $this->linkDb->getLinkFromUrl('http://public.tld') | 337 | $this->linkDb->getLinkFromUrl('http://public.tld') |
293 | ); | 338 | ); |
@@ -309,11 +354,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
309 | $this->assertEquals(0, count_private($this->linkDb)); | 354 | $this->assertEquals(0, count_private($this->linkDb)); |
310 | $this->assertEquals( | 355 | $this->assertEquals( |
311 | 0, | 356 | 0, |
312 | $this->linkDb['20001010_105536']['private'] | 357 | $this->linkDb[0]['private'] |
313 | ); | 358 | ); |
314 | $this->assertEquals( | 359 | $this->assertEquals( |
315 | 0, | 360 | 0, |
316 | $this->linkDb['20160225_205548']['private'] | 361 | $this->linkDb[1]['private'] |
317 | ); | 362 | ); |
318 | } | 363 | } |
319 | 364 | ||
@@ -333,11 +378,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
333 | $this->assertEquals(2, count_private($this->linkDb)); | 378 | $this->assertEquals(2, count_private($this->linkDb)); |
334 | $this->assertEquals( | 379 | $this->assertEquals( |
335 | 1, | 380 | 1, |
336 | $this->linkDb['20001010_105536']['private'] | 381 | $this->linkDb['0']['private'] |
337 | ); | 382 | ); |
338 | $this->assertEquals( | 383 | $this->assertEquals( |
339 | 1, | 384 | 1, |
340 | $this->linkDb['20160225_205548']['private'] | 385 | $this->linkDb['1']['private'] |
341 | ); | 386 | ); |
342 | } | 387 | } |
343 | 388 | ||
@@ -359,13 +404,12 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
359 | $this->assertEquals(2, count_private($this->linkDb)); | 404 | $this->assertEquals(2, count_private($this->linkDb)); |
360 | $this->assertEquals( | 405 | $this->assertEquals( |
361 | 1, | 406 | 1, |
362 | $this->linkDb['20001010_105536']['private'] | 407 | $this->linkDb[0]['private'] |
363 | ); | 408 | ); |
364 | $this->assertEquals( | 409 | $this->assertEquals( |
365 | 1, | 410 | 1, |
366 | $this->linkDb['20160225_205548']['private'] | 411 | $this->linkDb[1]['private'] |
367 | ); | 412 | ); |
368 | |||
369 | // re-import as public, enable overwriting | 413 | // re-import as public, enable overwriting |
370 | $post = array( | 414 | $post = array( |
371 | 'privacy' => 'public', | 415 | 'privacy' => 'public', |
@@ -380,11 +424,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
380 | $this->assertEquals(0, count_private($this->linkDb)); | 424 | $this->assertEquals(0, count_private($this->linkDb)); |
381 | $this->assertEquals( | 425 | $this->assertEquals( |
382 | 0, | 426 | 0, |
383 | $this->linkDb['20001010_105536']['private'] | 427 | $this->linkDb[0]['private'] |
384 | ); | 428 | ); |
385 | $this->assertEquals( | 429 | $this->assertEquals( |
386 | 0, | 430 | 0, |
387 | $this->linkDb['20160225_205548']['private'] | 431 | $this->linkDb[1]['private'] |
388 | ); | 432 | ); |
389 | } | 433 | } |
390 | 434 | ||
@@ -406,11 +450,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
406 | $this->assertEquals(0, count_private($this->linkDb)); | 450 | $this->assertEquals(0, count_private($this->linkDb)); |
407 | $this->assertEquals( | 451 | $this->assertEquals( |
408 | 0, | 452 | 0, |
409 | $this->linkDb['20001010_105536']['private'] | 453 | $this->linkDb['0']['private'] |
410 | ); | 454 | ); |
411 | $this->assertEquals( | 455 | $this->assertEquals( |
412 | 0, | 456 | 0, |
413 | $this->linkDb['20160225_205548']['private'] | 457 | $this->linkDb['1']['private'] |
414 | ); | 458 | ); |
415 | 459 | ||
416 | // re-import as private, enable overwriting | 460 | // re-import as private, enable overwriting |
@@ -427,11 +471,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
427 | $this->assertEquals(2, count_private($this->linkDb)); | 471 | $this->assertEquals(2, count_private($this->linkDb)); |
428 | $this->assertEquals( | 472 | $this->assertEquals( |
429 | 1, | 473 | 1, |
430 | $this->linkDb['20001010_105536']['private'] | 474 | $this->linkDb['0']['private'] |
431 | ); | 475 | ); |
432 | $this->assertEquals( | 476 | $this->assertEquals( |
433 | 1, | 477 | 1, |
434 | $this->linkDb['20160225_205548']['private'] | 478 | $this->linkDb['1']['private'] |
435 | ); | 479 | ); |
436 | } | 480 | } |
437 | 481 | ||
@@ -480,11 +524,11 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
480 | $this->assertEquals(0, count_private($this->linkDb)); | 524 | $this->assertEquals(0, count_private($this->linkDb)); |
481 | $this->assertEquals( | 525 | $this->assertEquals( |
482 | 'tag1 tag2 tag3 private secret', | 526 | 'tag1 tag2 tag3 private secret', |
483 | $this->linkDb['20001010_105536']['tags'] | 527 | $this->linkDb['0']['tags'] |
484 | ); | 528 | ); |
485 | $this->assertEquals( | 529 | $this->assertEquals( |
486 | 'tag1 tag2 tag3 public hello world', | 530 | 'tag1 tag2 tag3 public hello world', |
487 | $this->linkDb['20160225_205548']['tags'] | 531 | $this->linkDb['1']['tags'] |
488 | ); | 532 | ); |
489 | } | 533 | } |
490 | 534 | ||
@@ -507,16 +551,16 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
507 | $this->assertEquals(0, count_private($this->linkDb)); | 551 | $this->assertEquals(0, count_private($this->linkDb)); |
508 | $this->assertEquals( | 552 | $this->assertEquals( |
509 | 'tag1& tag2 "tag3" private secret', | 553 | 'tag1& tag2 "tag3" private secret', |
510 | $this->linkDb['20001010_105536']['tags'] | 554 | $this->linkDb['0']['tags'] |
511 | ); | 555 | ); |
512 | $this->assertEquals( | 556 | $this->assertEquals( |
513 | 'tag1& tag2 "tag3" public hello world', | 557 | 'tag1& tag2 "tag3" public hello world', |
514 | $this->linkDb['20160225_205548']['tags'] | 558 | $this->linkDb['1']['tags'] |
515 | ); | 559 | ); |
516 | } | 560 | } |
517 | 561 | ||
518 | /** | 562 | /** |
519 | * Ensure each imported bookmark has a unique linkdate | 563 | * Ensure each imported bookmark has a unique id |
520 | * | 564 | * |
521 | * See https://github.com/shaarli/Shaarli/issues/351 | 565 | * See https://github.com/shaarli/Shaarli/issues/351 |
522 | */ | 566 | */ |
@@ -531,16 +575,16 @@ class BookmarkImportTest extends PHPUnit_Framework_TestCase | |||
531 | $this->assertEquals(3, count($this->linkDb)); | 575 | $this->assertEquals(3, count($this->linkDb)); |
532 | $this->assertEquals(0, count_private($this->linkDb)); | 576 | $this->assertEquals(0, count_private($this->linkDb)); |
533 | $this->assertEquals( | 577 | $this->assertEquals( |
534 | '20160225_205548', | 578 | 0, |
535 | $this->linkDb['20160225_205548']['linkdate'] | 579 | $this->linkDb[0]['id'] |
536 | ); | 580 | ); |
537 | $this->assertEquals( | 581 | $this->assertEquals( |
538 | '20160225_205549', | 582 | 1, |
539 | $this->linkDb['20160225_205549']['linkdate'] | 583 | $this->linkDb[1]['id'] |
540 | ); | 584 | ); |
541 | $this->assertEquals( | 585 | $this->assertEquals( |
542 | '20160225_205550', | 586 | 2, |
543 | $this->linkDb['20160225_205550']['linkdate'] | 587 | $this->linkDb[2]['id'] |
544 | ); | 588 | ); |
545 | } | 589 | } |
546 | } | 590 | } |