]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | require_once 'application/NetscapeBookmarkUtils.php'; | |
4 | ||
5 | use Shaarli\Config\ConfigManager; | |
6 | ||
7 | /** | |
8 | * Utility function to load a file's metadata in a $_FILES-like array | |
9 | * | |
10 | * @param string $filename Basename of the file | |
11 | * | |
12 | * @return array A $_FILES-like array | |
13 | */ | |
14 | function file2array($filename) | |
15 | { | |
16 | return array( | |
17 | 'filetoupload' => array( | |
18 | 'name' => $filename, | |
19 | 'tmp_name' => __DIR__ . '/input/' . $filename, | |
20 | 'size' => filesize(__DIR__ . '/input/' . $filename) | |
21 | ) | |
22 | ); | |
23 | } | |
24 | ||
25 | ||
26 | /** | |
27 | * Netscape bookmark import | |
28 | */ | |
29 | class BookmarkImportTest extends PHPUnit_Framework_TestCase | |
30 | { | |
31 | /** | |
32 | * @var string datastore to test write operations | |
33 | */ | |
34 | protected static $testDatastore = 'sandbox/datastore.php'; | |
35 | ||
36 | /** | |
37 | * @var LinkDB private LinkDB instance | |
38 | */ | |
39 | protected $linkDb = null; | |
40 | ||
41 | /** | |
42 | * @var string Dummy page cache | |
43 | */ | |
44 | protected $pagecache = 'tests'; | |
45 | ||
46 | /** | |
47 | * @var ConfigManager instance. | |
48 | */ | |
49 | protected $conf; | |
50 | ||
51 | /** | |
52 | * @var string Save the current timezone. | |
53 | */ | |
54 | protected static $defaultTimeZone; | |
55 | ||
56 | public static function setUpBeforeClass() | |
57 | { | |
58 | self::$defaultTimeZone = date_default_timezone_get(); | |
59 | // Timezone without DST for test consistency | |
60 | date_default_timezone_set('Africa/Nairobi'); | |
61 | } | |
62 | ||
63 | /** | |
64 | * Resets test data before each test | |
65 | */ | |
66 | protected function setUp() | |
67 | { | |
68 | if (file_exists(self::$testDatastore)) { | |
69 | unlink(self::$testDatastore); | |
70 | } | |
71 | // start with an empty datastore | |
72 | file_put_contents(self::$testDatastore, '<?php /* S7QysKquBQA= */ ?>'); | |
73 | $this->linkDb = new LinkDB(self::$testDatastore, true, false); | |
74 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | |
75 | $this->conf->set('resource.page_cache', $this->pagecache); | |
76 | } | |
77 | ||
78 | public static function tearDownAfterClass() | |
79 | { | |
80 | date_default_timezone_set(self::$defaultTimeZone); | |
81 | } | |
82 | ||
83 | /** | |
84 | * Attempt to import bookmarks from an empty file | |
85 | */ | |
86 | public function testImportEmptyData() | |
87 | { | |
88 | $files = file2array('empty.htm'); | |
89 | $this->assertEquals( | |
90 | 'File empty.htm (0 bytes) has an unknown file format.' | |
91 | .' Nothing was imported.', | |
92 | NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf) | |
93 | ); | |
94 | $this->assertEquals(0, count($this->linkDb)); | |
95 | } | |
96 | ||
97 | /** | |
98 | * Attempt to import bookmarks from a file with no Doctype | |
99 | */ | |
100 | public function testImportNoDoctype() | |
101 | { | |
102 | $files = file2array('no_doctype.htm'); | |
103 | $this->assertEquals( | |
104 | 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', | |
105 | NetscapeBookmarkUtils::import(NULL, $files, NULL, $this->conf) | |
106 | ); | |
107 | $this->assertEquals(0, count($this->linkDb)); | |
108 | } | |
109 | ||
110 | /** | |
111 | * Ensure IE dumps are supported | |
112 | */ | |
113 | public function testImportInternetExplorerEncoding() | |
114 | { | |
115 | $files = file2array('internet_explorer_encoding.htm'); | |
116 | $this->assertEquals( | |
117 | 'File internet_explorer_encoding.htm (356 bytes) was successfully processed:' | |
118 | .' 1 links imported, 0 links overwritten, 0 links skipped.', | |
119 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) | |
120 | ); | |
121 | $this->assertEquals(1, count($this->linkDb)); | |
122 | $this->assertEquals(0, count_private($this->linkDb)); | |
123 | ||
124 | $this->assertEquals( | |
125 | array( | |
126 | 'id' => 0, | |
127 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160618_203944'), | |
128 | 'title' => 'Hg Init a Mercurial tutorial by Joel Spolsky', | |
129 | 'url' => 'http://hginit.com/', | |
130 | 'description' => '', | |
131 | 'private' => 0, | |
132 | 'tags' => '', | |
133 | 'shorturl' => 'La37cg', | |
134 | ), | |
135 | $this->linkDb->getLinkFromUrl('http://hginit.com/') | |
136 | ); | |
137 | } | |
138 | ||
139 | /** | |
140 | * Import bookmarks nested in a folder hierarchy | |
141 | */ | |
142 | public function testImportNested() | |
143 | { | |
144 | $files = file2array('netscape_nested.htm'); | |
145 | $this->assertEquals( | |
146 | 'File netscape_nested.htm (1337 bytes) was successfully processed:' | |
147 | .' 8 links imported, 0 links overwritten, 0 links skipped.', | |
148 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) | |
149 | ); | |
150 | $this->assertEquals(8, count($this->linkDb)); | |
151 | $this->assertEquals(2, count_private($this->linkDb)); | |
152 | ||
153 | $this->assertEquals( | |
154 | array( | |
155 | 'id' => 0, | |
156 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235541'), | |
157 | 'title' => 'Nested 1', | |
158 | 'url' => 'http://nest.ed/1', | |
159 | 'description' => '', | |
160 | 'private' => 0, | |
161 | 'tags' => 'tag1 tag2', | |
162 | 'shorturl' => 'KyDNKA', | |
163 | ), | |
164 | $this->linkDb->getLinkFromUrl('http://nest.ed/1') | |
165 | ); | |
166 | $this->assertEquals( | |
167 | array( | |
168 | 'id' => 1, | |
169 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235542'), | |
170 | 'title' => 'Nested 1-1', | |
171 | 'url' => 'http://nest.ed/1-1', | |
172 | 'description' => '', | |
173 | 'private' => 0, | |
174 | 'tags' => 'folder1 tag1 tag2', | |
175 | 'shorturl' => 'T2LnXg', | |
176 | ), | |
177 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-1') | |
178 | ); | |
179 | $this->assertEquals( | |
180 | array( | |
181 | 'id' => 2, | |
182 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235547'), | |
183 | 'title' => 'Nested 1-2', | |
184 | 'url' => 'http://nest.ed/1-2', | |
185 | 'description' => '', | |
186 | 'private' => 0, | |
187 | 'tags' => 'folder1 tag3 tag4', | |
188 | 'shorturl' => '46SZxA', | |
189 | ), | |
190 | $this->linkDb->getLinkFromUrl('http://nest.ed/1-2') | |
191 | ); | |
192 | $this->assertEquals( | |
193 | array( | |
194 | 'id' => 3, | |
195 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160202_202222'), | |
196 | 'title' => 'Nested 2-1', | |
197 | 'url' => 'http://nest.ed/2-1', | |
198 | 'description' => 'First link of the second section', | |
199 | 'private' => 1, | |
200 | 'tags' => 'folder2', | |
201 | 'shorturl' => '4UHOSw', | |
202 | ), | |
203 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-1') | |
204 | ); | |
205 | $this->assertEquals( | |
206 | array( | |
207 | 'id' => 4, | |
208 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160119_230227'), | |
209 | 'title' => 'Nested 2-2', | |
210 | 'url' => 'http://nest.ed/2-2', | |
211 | 'description' => 'Second link of the second section', | |
212 | 'private' => 1, | |
213 | 'tags' => 'folder2', | |
214 | 'shorturl' => 'yfzwbw', | |
215 | ), | |
216 | $this->linkDb->getLinkFromUrl('http://nest.ed/2-2') | |
217 | ); | |
218 | $this->assertEquals( | |
219 | array( | |
220 | 'id' => 5, | |
221 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160202_202222'), | |
222 | 'title' => 'Nested 3-1', | |
223 | 'url' => 'http://nest.ed/3-1', | |
224 | 'description' => '', | |
225 | 'private' => 0, | |
226 | 'tags' => 'folder3 folder3-1 tag3', | |
227 | 'shorturl' => 'UwxIUQ', | |
228 | ), | |
229 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-1') | |
230 | ); | |
231 | $this->assertEquals( | |
232 | array( | |
233 | 'id' => 6, | |
234 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160119_230227'), | |
235 | 'title' => 'Nested 3-2', | |
236 | 'url' => 'http://nest.ed/3-2', | |
237 | 'description' => '', | |
238 | 'private' => 0, | |
239 | 'tags' => 'folder3 folder3-1', | |
240 | 'shorturl' => 'p8dyZg', | |
241 | ), | |
242 | $this->linkDb->getLinkFromUrl('http://nest.ed/3-2') | |
243 | ); | |
244 | $this->assertEquals( | |
245 | array( | |
246 | 'id' => 7, | |
247 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160229_111541'), | |
248 | 'title' => 'Nested 2', | |
249 | 'url' => 'http://nest.ed/2', | |
250 | 'description' => '', | |
251 | 'private' => 0, | |
252 | 'tags' => 'tag4', | |
253 | 'shorturl' => 'Gt3Uug', | |
254 | ), | |
255 | $this->linkDb->getLinkFromUrl('http://nest.ed/2') | |
256 | ); | |
257 | } | |
258 | ||
259 | /** | |
260 | * Import bookmarks with the default privacy setting (reuse from file) | |
261 | * | |
262 | * The $_POST array is not set. | |
263 | */ | |
264 | public function testImportDefaultPrivacyNoPost() | |
265 | { | |
266 | $files = file2array('netscape_basic.htm'); | |
267 | $this->assertEquals( | |
268 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
269 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
270 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) | |
271 | ); | |
272 | ||
273 | $this->assertEquals(2, count($this->linkDb)); | |
274 | $this->assertEquals(1, count_private($this->linkDb)); | |
275 | ||
276 | $this->assertEquals( | |
277 | array( | |
278 | 'id' => 0, | |
279 | // Old link - UTC+4 (note that TZ in the import file is ignored). | |
280 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20001010_135536'), | |
281 | 'title' => 'Secret stuff', | |
282 | 'url' => 'https://private.tld', | |
283 | 'description' => "Super-secret stuff you're not supposed to know about", | |
284 | 'private' => 1, | |
285 | 'tags' => 'private secret', | |
286 | 'shorturl' => 'EokDtA', | |
287 | ), | |
288 | $this->linkDb->getLinkFromUrl('https://private.tld') | |
289 | ); | |
290 | $this->assertEquals( | |
291 | array( | |
292 | 'id' => 1, | |
293 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235548'), | |
294 | 'title' => 'Public stuff', | |
295 | 'url' => 'http://public.tld', | |
296 | 'description' => '', | |
297 | 'private' => 0, | |
298 | 'tags' => 'public hello world', | |
299 | 'shorturl' => 'Er9ddA', | |
300 | ), | |
301 | $this->linkDb->getLinkFromUrl('http://public.tld') | |
302 | ); | |
303 | } | |
304 | ||
305 | /** | |
306 | * Import bookmarks with the default privacy setting (reuse from file) | |
307 | */ | |
308 | public function testImportKeepPrivacy() | |
309 | { | |
310 | $post = array('privacy' => 'default'); | |
311 | $files = file2array('netscape_basic.htm'); | |
312 | $this->assertEquals( | |
313 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
314 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
315 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
316 | ); | |
317 | $this->assertEquals(2, count($this->linkDb)); | |
318 | $this->assertEquals(1, count_private($this->linkDb)); | |
319 | ||
320 | $this->assertEquals( | |
321 | array( | |
322 | 'id' => 0, | |
323 | // Note that TZ in the import file is ignored. | |
324 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20001010_135536'), | |
325 | 'title' => 'Secret stuff', | |
326 | 'url' => 'https://private.tld', | |
327 | 'description' => "Super-secret stuff you're not supposed to know about", | |
328 | 'private' => 1, | |
329 | 'tags' => 'private secret', | |
330 | 'shorturl' => 'EokDtA', | |
331 | ), | |
332 | $this->linkDb->getLinkFromUrl('https://private.tld') | |
333 | ); | |
334 | $this->assertEquals( | |
335 | array( | |
336 | 'id' => 1, | |
337 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160225_235548'), | |
338 | 'title' => 'Public stuff', | |
339 | 'url' => 'http://public.tld', | |
340 | 'description' => '', | |
341 | 'private' => 0, | |
342 | 'tags' => 'public hello world', | |
343 | 'shorturl' => 'Er9ddA', | |
344 | ), | |
345 | $this->linkDb->getLinkFromUrl('http://public.tld') | |
346 | ); | |
347 | } | |
348 | ||
349 | /** | |
350 | * Import links as public | |
351 | */ | |
352 | public function testImportAsPublic() | |
353 | { | |
354 | $post = array('privacy' => 'public'); | |
355 | $files = file2array('netscape_basic.htm'); | |
356 | $this->assertEquals( | |
357 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
358 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
359 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
360 | ); | |
361 | $this->assertEquals(2, count($this->linkDb)); | |
362 | $this->assertEquals(0, count_private($this->linkDb)); | |
363 | $this->assertEquals( | |
364 | 0, | |
365 | $this->linkDb[0]['private'] | |
366 | ); | |
367 | $this->assertEquals( | |
368 | 0, | |
369 | $this->linkDb[1]['private'] | |
370 | ); | |
371 | } | |
372 | ||
373 | /** | |
374 | * Import links as private | |
375 | */ | |
376 | public function testImportAsPrivate() | |
377 | { | |
378 | $post = array('privacy' => 'private'); | |
379 | $files = file2array('netscape_basic.htm'); | |
380 | $this->assertEquals( | |
381 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
382 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
383 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
384 | ); | |
385 | $this->assertEquals(2, count($this->linkDb)); | |
386 | $this->assertEquals(2, count_private($this->linkDb)); | |
387 | $this->assertEquals( | |
388 | 1, | |
389 | $this->linkDb['0']['private'] | |
390 | ); | |
391 | $this->assertEquals( | |
392 | 1, | |
393 | $this->linkDb['1']['private'] | |
394 | ); | |
395 | } | |
396 | ||
397 | /** | |
398 | * Overwrite private links so they become public | |
399 | */ | |
400 | public function testOverwriteAsPublic() | |
401 | { | |
402 | $files = file2array('netscape_basic.htm'); | |
403 | ||
404 | // import links as private | |
405 | $post = array('privacy' => 'private'); | |
406 | $this->assertEquals( | |
407 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
408 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
409 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
410 | ); | |
411 | $this->assertEquals(2, count($this->linkDb)); | |
412 | $this->assertEquals(2, count_private($this->linkDb)); | |
413 | $this->assertEquals( | |
414 | 1, | |
415 | $this->linkDb[0]['private'] | |
416 | ); | |
417 | $this->assertEquals( | |
418 | 1, | |
419 | $this->linkDb[1]['private'] | |
420 | ); | |
421 | // re-import as public, enable overwriting | |
422 | $post = array( | |
423 | 'privacy' => 'public', | |
424 | 'overwrite' => 'true' | |
425 | ); | |
426 | $this->assertEquals( | |
427 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
428 | .' 2 links imported, 2 links overwritten, 0 links skipped.', | |
429 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
430 | ); | |
431 | $this->assertEquals(2, count($this->linkDb)); | |
432 | $this->assertEquals(0, count_private($this->linkDb)); | |
433 | $this->assertEquals( | |
434 | 0, | |
435 | $this->linkDb[0]['private'] | |
436 | ); | |
437 | $this->assertEquals( | |
438 | 0, | |
439 | $this->linkDb[1]['private'] | |
440 | ); | |
441 | } | |
442 | ||
443 | /** | |
444 | * Overwrite public links so they become private | |
445 | */ | |
446 | public function testOverwriteAsPrivate() | |
447 | { | |
448 | $files = file2array('netscape_basic.htm'); | |
449 | ||
450 | // import links as public | |
451 | $post = array('privacy' => 'public'); | |
452 | $this->assertEquals( | |
453 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
454 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
455 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
456 | ); | |
457 | $this->assertEquals(2, count($this->linkDb)); | |
458 | $this->assertEquals(0, count_private($this->linkDb)); | |
459 | $this->assertEquals( | |
460 | 0, | |
461 | $this->linkDb['0']['private'] | |
462 | ); | |
463 | $this->assertEquals( | |
464 | 0, | |
465 | $this->linkDb['1']['private'] | |
466 | ); | |
467 | ||
468 | // re-import as private, enable overwriting | |
469 | $post = array( | |
470 | 'privacy' => 'private', | |
471 | 'overwrite' => 'true' | |
472 | ); | |
473 | $this->assertEquals( | |
474 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
475 | .' 2 links imported, 2 links overwritten, 0 links skipped.', | |
476 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
477 | ); | |
478 | $this->assertEquals(2, count($this->linkDb)); | |
479 | $this->assertEquals(2, count_private($this->linkDb)); | |
480 | $this->assertEquals( | |
481 | 1, | |
482 | $this->linkDb['0']['private'] | |
483 | ); | |
484 | $this->assertEquals( | |
485 | 1, | |
486 | $this->linkDb['1']['private'] | |
487 | ); | |
488 | } | |
489 | ||
490 | /** | |
491 | * Attept to import the same links twice without enabling overwriting | |
492 | */ | |
493 | public function testSkipOverwrite() | |
494 | { | |
495 | $post = array('privacy' => 'public'); | |
496 | $files = file2array('netscape_basic.htm'); | |
497 | $this->assertEquals( | |
498 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
499 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
500 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
501 | ); | |
502 | $this->assertEquals(2, count($this->linkDb)); | |
503 | $this->assertEquals(0, count_private($this->linkDb)); | |
504 | ||
505 | // re-import as private, DO NOT enable overwriting | |
506 | $post = array('privacy' => 'private'); | |
507 | $this->assertEquals( | |
508 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
509 | .' 0 links imported, 0 links overwritten, 2 links skipped.', | |
510 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
511 | ); | |
512 | $this->assertEquals(2, count($this->linkDb)); | |
513 | $this->assertEquals(0, count_private($this->linkDb)); | |
514 | } | |
515 | ||
516 | /** | |
517 | * Add user-specified tags to all imported bookmarks | |
518 | */ | |
519 | public function testSetDefaultTags() | |
520 | { | |
521 | $post = array( | |
522 | 'privacy' => 'public', | |
523 | 'default_tags' => 'tag1,tag2 tag3' | |
524 | ); | |
525 | $files = file2array('netscape_basic.htm'); | |
526 | $this->assertEquals( | |
527 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
528 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
529 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
530 | ); | |
531 | $this->assertEquals(2, count($this->linkDb)); | |
532 | $this->assertEquals(0, count_private($this->linkDb)); | |
533 | $this->assertEquals( | |
534 | 'tag1 tag2 tag3 private secret', | |
535 | $this->linkDb['0']['tags'] | |
536 | ); | |
537 | $this->assertEquals( | |
538 | 'tag1 tag2 tag3 public hello world', | |
539 | $this->linkDb['1']['tags'] | |
540 | ); | |
541 | } | |
542 | ||
543 | /** | |
544 | * The user-specified tags contain characters to be escaped | |
545 | */ | |
546 | public function testSanitizeDefaultTags() | |
547 | { | |
548 | $post = array( | |
549 | 'privacy' => 'public', | |
550 | 'default_tags' => 'tag1&,tag2 "tag3"' | |
551 | ); | |
552 | $files = file2array('netscape_basic.htm'); | |
553 | $this->assertEquals( | |
554 | 'File netscape_basic.htm (482 bytes) was successfully processed:' | |
555 | .' 2 links imported, 0 links overwritten, 0 links skipped.', | |
556 | NetscapeBookmarkUtils::import($post, $files, $this->linkDb, $this->conf) | |
557 | ); | |
558 | $this->assertEquals(2, count($this->linkDb)); | |
559 | $this->assertEquals(0, count_private($this->linkDb)); | |
560 | $this->assertEquals( | |
561 | 'tag1& tag2 "tag3" private secret', | |
562 | $this->linkDb['0']['tags'] | |
563 | ); | |
564 | $this->assertEquals( | |
565 | 'tag1& tag2 "tag3" public hello world', | |
566 | $this->linkDb['1']['tags'] | |
567 | ); | |
568 | } | |
569 | ||
570 | /** | |
571 | * Ensure each imported bookmark has a unique id | |
572 | * | |
573 | * See https://github.com/shaarli/Shaarli/issues/351 | |
574 | */ | |
575 | public function testImportSameDate() | |
576 | { | |
577 | $files = file2array('same_date.htm'); | |
578 | $this->assertEquals( | |
579 | 'File same_date.htm (453 bytes) was successfully processed:' | |
580 | .' 3 links imported, 0 links overwritten, 0 links skipped.', | |
581 | NetscapeBookmarkUtils::import(array(), $files, $this->linkDb, $this->conf) | |
582 | ); | |
583 | $this->assertEquals(3, count($this->linkDb)); | |
584 | $this->assertEquals(0, count_private($this->linkDb)); | |
585 | $this->assertEquals( | |
586 | 0, | |
587 | $this->linkDb[0]['id'] | |
588 | ); | |
589 | $this->assertEquals( | |
590 | 1, | |
591 | $this->linkDb[1]['id'] | |
592 | ); | |
593 | $this->assertEquals( | |
594 | 2, | |
595 | $this->linkDb[2]['id'] | |
596 | ); | |
597 | } | |
598 | } |