3 namespace Shaarli\Netscape
;
6 use Psr\Http\Message\UploadedFileInterface
;
7 use Shaarli\Bookmark\Bookmark
;
8 use Shaarli\Bookmark\BookmarkFileService
;
9 use Shaarli\Bookmark\BookmarkFilter
;
10 use Shaarli\Config\ConfigManager
;
13 use Slim\Http\UploadedFile
;
16 * Utility function to load a file's metadata in a $_FILES-like array
18 * @param string $filename Basename of the file
20 * @return UploadedFileInterface Upload file in PSR-7 compatible object
22 function file2array($filename)
24 return new UploadedFile(
25 __DIR__
. '/input/' . $filename,
28 filesize(__DIR__
. '/input/' . $filename)
34 * Netscape bookmark import
36 class BookmarkImportTest
extends TestCase
39 * @var string datastore to test write operations
41 protected static $testDatastore = 'sandbox/datastore.php';
44 * @var string History file path
46 protected static $historyFilePath = 'sandbox/history.php';
49 * @var BookmarkFileService private LinkDB instance
51 protected $bookmarkService = null;
54 * @var string Dummy page cache
56 protected $pagecache = 'tests';
59 * @var ConfigManager instance.
64 * @var History instance.
69 * @var NetscapeBookmarkUtils
71 protected $netscapeBookmarkUtils;
74 * @var string Save the current timezone.
76 protected static $defaultTimeZone;
78 public static function setUpBeforeClass(): void
80 self
::$defaultTimeZone = date_default_timezone_get();
81 // Timezone without DST for test consistency
82 date_default_timezone_set('Africa/Nairobi');
86 * Resets test data before each test
88 protected function setUp(): void
90 if (file_exists(self
::$testDatastore)) {
91 unlink(self
::$testDatastore);
93 // start with an empty datastore
94 file_put_contents(self
::$testDatastore, '<?php /* S7QysKquBQA= */ ?>');
96 $this->conf
= new ConfigManager('tests/utils/config/configJson');
97 $this->conf
->set('resource.page_cache', $this->pagecache
);
98 $this->conf
->set('resource.datastore', self
::$testDatastore);
99 $this->history
= new History(self
::$historyFilePath);
100 $this->bookmarkService
= new BookmarkFileService($this->conf
, $this->history
, true);
101 $this->netscapeBookmarkUtils
= new NetscapeBookmarkUtils($this->bookmarkService
, $this->conf
, $this->history
);
105 * Delete history file.
107 protected function tearDown(): void
109 @unlink(self
::$historyFilePath);
112 public static function tearDownAfterClass(): void
114 date_default_timezone_set(self
::$defaultTimeZone);
118 * Attempt to import bookmarks from an empty file
120 public function testImportEmptyData()
122 $files = file2array('empty.htm');
124 'File empty.htm (0 bytes) has an unknown file format.'
125 .' Nothing was imported.',
126 $this->netscapeBookmarkUtils
->import(null, $files)
128 $this->assertEquals(0, $this->bookmarkService
->count());
132 * Attempt to import bookmarks from a file with no Doctype
134 public function testImportNoDoctype()
136 $files = file2array('no_doctype.htm');
138 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.',
139 $this->netscapeBookmarkUtils
->import(null, $files)
141 $this->assertEquals(0, $this->bookmarkService
->count());
145 * Attempt to import bookmarks from a file with a lowercase Doctype
147 public function testImportLowecaseDoctype()
149 $files = file2array('lowercase_doctype.htm');
150 $this->assertStringMatchesFormat(
151 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:'
152 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
153 $this->netscapeBookmarkUtils
->import(null, $files)
155 $this->assertEquals(2, $this->bookmarkService
->count());
160 * Ensure IE dumps are supported
162 public function testImportInternetExplorerEncoding()
164 $files = file2array('internet_explorer_encoding.htm');
165 $this->assertStringMatchesFormat(
166 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
167 .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
168 $this->netscapeBookmarkUtils
->import([], $files)
170 $this->assertEquals(1, $this->bookmarkService
->count());
171 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
173 $bookmark = $this->bookmarkService
->findByUrl('http://hginit.com/');
174 $this->assertEquals(0, $bookmark->getId());
176 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160618_203944'),
177 $bookmark->getCreated()
179 $this->assertEquals('Hg Init a Mercurial tutorial by Joel Spolsky', $bookmark->getTitle());
180 $this->assertEquals('http://hginit.com/', $bookmark->getUrl());
181 $this->assertEquals('', $bookmark->getDescription());
182 $this->assertFalse($bookmark->isPrivate());
183 $this->assertEquals('', $bookmark->getTagsString());
184 $this->assertEquals('La37cg', $bookmark->getShortUrl());
188 * Import bookmarks nested in a folder hierarchy
190 public function testImportNested()
192 $files = file2array('netscape_nested.htm');
193 $this->assertStringMatchesFormat(
194 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
195 .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
196 $this->netscapeBookmarkUtils
->import([], $files)
198 $this->assertEquals(8, $this->bookmarkService
->count());
199 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
201 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1');
202 $this->assertEquals(0, $bookmark->getId());
204 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235541'),
205 $bookmark->getCreated()
207 $this->assertEquals('Nested 1', $bookmark->getTitle());
208 $this->assertEquals('http://nest.ed/1', $bookmark->getUrl());
209 $this->assertEquals('', $bookmark->getDescription());
210 $this->assertFalse($bookmark->isPrivate());
211 $this->assertEquals('tag1 tag2', $bookmark->getTagsString());
212 $this->assertEquals('KyDNKA', $bookmark->getShortUrl());
214 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1-1');
215 $this->assertEquals(1, $bookmark->getId());
217 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235542'),
218 $bookmark->getCreated()
220 $this->assertEquals('Nested 1-1', $bookmark->getTitle());
221 $this->assertEquals('http://nest.ed/1-1', $bookmark->getUrl());
222 $this->assertEquals('', $bookmark->getDescription());
223 $this->assertFalse($bookmark->isPrivate());
224 $this->assertEquals('folder1 tag1 tag2', $bookmark->getTagsString());
225 $this->assertEquals('T2LnXg', $bookmark->getShortUrl());
227 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1-2');
228 $this->assertEquals(2, $bookmark->getId());
230 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235547'),
231 $bookmark->getCreated()
233 $this->assertEquals('Nested 1-2', $bookmark->getTitle());
234 $this->assertEquals('http://nest.ed/1-2', $bookmark->getUrl());
235 $this->assertEquals('', $bookmark->getDescription());
236 $this->assertFalse($bookmark->isPrivate());
237 $this->assertEquals('folder1 tag3 tag4', $bookmark->getTagsString());
238 $this->assertEquals('46SZxA', $bookmark->getShortUrl());
240 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2-1');
241 $this->assertEquals(3, $bookmark->getId());
243 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160202_202222'),
244 $bookmark->getCreated()
246 $this->assertEquals('Nested 2-1', $bookmark->getTitle());
247 $this->assertEquals('http://nest.ed/2-1', $bookmark->getUrl());
248 $this->assertEquals('First link of the second section', $bookmark->getDescription());
249 $this->assertTrue($bookmark->isPrivate());
250 $this->assertEquals('folder2', $bookmark->getTagsString());
251 $this->assertEquals('4UHOSw', $bookmark->getShortUrl());
253 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2-2');
254 $this->assertEquals(4, $bookmark->getId());
256 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160119_230227'),
257 $bookmark->getCreated()
259 $this->assertEquals('Nested 2-2', $bookmark->getTitle());
260 $this->assertEquals('http://nest.ed/2-2', $bookmark->getUrl());
261 $this->assertEquals('Second link of the second section', $bookmark->getDescription());
262 $this->assertTrue($bookmark->isPrivate());
263 $this->assertEquals('folder2', $bookmark->getTagsString());
264 $this->assertEquals('yfzwbw', $bookmark->getShortUrl());
266 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/3-1');
267 $this->assertEquals(5, $bookmark->getId());
269 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160202_202222'),
270 $bookmark->getCreated()
272 $this->assertEquals('Nested 3-1', $bookmark->getTitle());
273 $this->assertEquals('http://nest.ed/3-1', $bookmark->getUrl());
274 $this->assertEquals('', $bookmark->getDescription());
275 $this->assertFalse($bookmark->isPrivate());
276 $this->assertEquals('folder3 folder3-1 tag3', $bookmark->getTagsString());
277 $this->assertEquals('UwxIUQ', $bookmark->getShortUrl());
279 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/3-2');
280 $this->assertEquals(6, $bookmark->getId());
282 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160119_230227'),
283 $bookmark->getCreated()
285 $this->assertEquals('Nested 3-2', $bookmark->getTitle());
286 $this->assertEquals('http://nest.ed/3-2', $bookmark->getUrl());
287 $this->assertEquals('', $bookmark->getDescription());
288 $this->assertFalse($bookmark->isPrivate());
289 $this->assertEquals('folder3 folder3-1', $bookmark->getTagsString());
290 $this->assertEquals('p8dyZg', $bookmark->getShortUrl());
292 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2');
293 $this->assertEquals(7, $bookmark->getId());
295 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160229_111541'),
296 $bookmark->getCreated()
298 $this->assertEquals('Nested 2', $bookmark->getTitle());
299 $this->assertEquals('http://nest.ed/2', $bookmark->getUrl());
300 $this->assertEquals('', $bookmark->getDescription());
301 $this->assertFalse($bookmark->isPrivate());
302 $this->assertEquals('tag4', $bookmark->getTagsString());
303 $this->assertEquals('Gt3Uug', $bookmark->getShortUrl());
307 * Import bookmarks with the default privacy setting (reuse from file)
309 * The $_POST array is not set.
311 public function testImportDefaultPrivacyNoPost()
313 $files = file2array('netscape_basic.htm');
314 $this->assertStringMatchesFormat(
315 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
316 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
317 $this->netscapeBookmarkUtils
->import([], $files)
320 $this->assertEquals(2, $this->bookmarkService
->count());
321 $this->assertEquals(1, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
323 $bookmark = $this->bookmarkService
->findByUrl('https://private.tld');
324 $this->assertEquals(0, $bookmark->getId());
326 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20001010_135536'),
327 $bookmark->getCreated()
329 $this->assertEquals('Secret stuff', $bookmark->getTitle());
330 $this->assertEquals('https://private.tld', $bookmark->getUrl());
331 $this->assertEquals('Super-secret stuff you\'re not supposed to know about', $bookmark->getDescription());
332 $this->assertTrue($bookmark->isPrivate());
333 $this->assertEquals('private secret', $bookmark->getTagsString());
334 $this->assertEquals('EokDtA', $bookmark->getShortUrl());
336 $bookmark = $this->bookmarkService
->findByUrl('http://public.tld');
337 $this->assertEquals(1, $bookmark->getId());
339 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235548'),
340 $bookmark->getCreated()
342 $this->assertEquals('Public stuff', $bookmark->getTitle());
343 $this->assertEquals('http://public.tld', $bookmark->getUrl());
344 $this->assertEquals('', $bookmark->getDescription());
345 $this->assertFalse($bookmark->isPrivate());
346 $this->assertEquals('public hello world', $bookmark->getTagsString());
347 $this->assertEquals('Er9ddA', $bookmark->getShortUrl());
351 * Import bookmarks with the default privacy setting (reuse from file)
353 public function testImportKeepPrivacy()
355 $post = array('privacy' => 'default');
356 $files = file2array('netscape_basic.htm');
357 $this->assertStringMatchesFormat(
358 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
359 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
360 $this->netscapeBookmarkUtils
->import($post, $files)
363 $this->assertEquals(2, $this->bookmarkService
->count());
364 $this->assertEquals(1, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
366 $bookmark = $this->bookmarkService
->findByUrl('https://private.tld');
367 $this->assertEquals(0, $bookmark->getId());
369 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20001010_135536'),
370 $bookmark->getCreated()
372 $this->assertEquals('Secret stuff', $bookmark->getTitle());
373 $this->assertEquals('https://private.tld', $bookmark->getUrl());
374 $this->assertEquals('Super-secret stuff you\'re not supposed to know about', $bookmark->getDescription());
375 $this->assertTrue($bookmark->isPrivate());
376 $this->assertEquals('private secret', $bookmark->getTagsString());
377 $this->assertEquals('EokDtA', $bookmark->getShortUrl());
379 $bookmark = $this->bookmarkService
->findByUrl('http://public.tld');
380 $this->assertEquals(1, $bookmark->getId());
382 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235548'),
383 $bookmark->getCreated()
385 $this->assertEquals('Public stuff', $bookmark->getTitle());
386 $this->assertEquals('http://public.tld', $bookmark->getUrl());
387 $this->assertEquals('', $bookmark->getDescription());
388 $this->assertFalse($bookmark->isPrivate());
389 $this->assertEquals('public hello world', $bookmark->getTagsString());
390 $this->assertEquals('Er9ddA', $bookmark->getShortUrl());
394 * Import bookmarks as public
396 public function testImportAsPublic()
398 $post = array('privacy' => 'public');
399 $files = file2array('netscape_basic.htm');
400 $this->assertStringMatchesFormat(
401 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
402 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
403 $this->netscapeBookmarkUtils
->import($post, $files)
405 $this->assertEquals(2, $this->bookmarkService
->count());
406 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
407 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
408 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
412 * Import bookmarks as private
414 public function testImportAsPrivate()
416 $post = array('privacy' => 'private');
417 $files = file2array('netscape_basic.htm');
418 $this->assertStringMatchesFormat(
419 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
420 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
421 $this->netscapeBookmarkUtils
->import($post, $files)
423 $this->assertEquals(2, $this->bookmarkService
->count());
424 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
425 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
426 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
430 * Overwrite private bookmarks so they become public
432 public function testOverwriteAsPublic()
434 $files = file2array('netscape_basic.htm');
436 // import bookmarks as private
437 $post = array('privacy' => 'private');
438 $this->assertStringMatchesFormat(
439 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
440 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
441 $this->netscapeBookmarkUtils
->import($post, $files)
443 $this->assertEquals(2, $this->bookmarkService
->count());
444 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
445 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
446 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
448 // re-import as public, enable overwriting
450 'privacy' => 'public',
451 'overwrite' => 'true'
453 $this->assertStringMatchesFormat(
454 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
455 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
456 $this->netscapeBookmarkUtils
->import($post, $files)
458 $this->assertEquals(2, $this->bookmarkService
->count());
459 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
460 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
461 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
465 * Overwrite public bookmarks so they become private
467 public function testOverwriteAsPrivate()
469 $files = file2array('netscape_basic.htm');
471 // import bookmarks as public
472 $post = array('privacy' => 'public');
473 $this->assertStringMatchesFormat(
474 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
475 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
476 $this->netscapeBookmarkUtils
->import($post, $files)
478 $this->assertEquals(2, $this->bookmarkService
->count());
479 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
480 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
481 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
483 // re-import as private, enable overwriting
485 'privacy' => 'private',
486 'overwrite' => 'true'
488 $this->assertStringMatchesFormat(
489 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
490 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
491 $this->netscapeBookmarkUtils
->import($post, $files)
493 $this->assertEquals(2, $this->bookmarkService
->count());
494 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
495 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
496 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
500 * Attept to import the same bookmarks twice without enabling overwriting
502 public function testSkipOverwrite()
504 $post = array('privacy' => 'public');
505 $files = file2array('netscape_basic.htm');
506 $this->assertStringMatchesFormat(
507 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
508 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
509 $this->netscapeBookmarkUtils
->import($post, $files)
511 $this->assertEquals(2, $this->bookmarkService
->count());
512 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
514 // re-import as private, DO NOT enable overwriting
515 $post = array('privacy' => 'private');
516 $this->assertStringMatchesFormat(
517 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
518 .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.',
519 $this->netscapeBookmarkUtils
->import($post, $files)
521 $this->assertEquals(2, $this->bookmarkService
->count());
522 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
526 * Add user-specified tags to all imported bookmarks
528 public function testSetDefaultTags()
531 'privacy' => 'public',
532 'default_tags' => 'tag1,tag2 tag3'
534 $files = file2array('netscape_basic.htm');
535 $this->assertStringMatchesFormat(
536 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
537 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
538 $this->netscapeBookmarkUtils
->import($post, $files)
540 $this->assertEquals(2, $this->bookmarkService
->count());
541 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
542 $this->assertEquals('tag1 tag2 tag3 private secret', $this->bookmarkService
->get(0)->getTagsString());
543 $this->assertEquals('tag1 tag2 tag3 public hello world', $this->bookmarkService
->get(1)->getTagsString());
547 * The user-specified tags contain characters to be escaped
549 public function testSanitizeDefaultTags()
552 'privacy' => 'public',
553 'default_tags' => 'tag1&,tag2 "tag3"'
555 $files = file2array('netscape_basic.htm');
556 $this->assertStringMatchesFormat(
557 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
558 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
559 $this->netscapeBookmarkUtils
->import($post, $files)
561 $this->assertEquals(2, $this->bookmarkService
->count());
562 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
564 'tag1& tag2 "tag3" private secret',
565 $this->bookmarkService
->get(0)->getTagsString()
568 'tag1& tag2 "tag3" public hello world',
569 $this->bookmarkService
->get(1)->getTagsString()
574 * Ensure each imported bookmark has a unique id
576 * See https://github.com/shaarli/Shaarli/issues/351
578 public function testImportSameDate()
580 $files = file2array('same_date.htm');
581 $this->assertStringMatchesFormat(
582 'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
583 .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
584 $this->netscapeBookmarkUtils
->import(array(), $files)
586 $this->assertEquals(3, $this->bookmarkService
->count());
587 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
588 $this->assertEquals(0, $this->bookmarkService
->get(0)->getId());
589 $this->assertEquals(1, $this->bookmarkService
->get(1)->getId());
590 $this->assertEquals(2, $this->bookmarkService
->get(2)->getId());
593 public function testImportCreateUpdateHistory()
596 'privacy' => 'public',
597 'overwrite' => 'true',
599 $files = file2array('netscape_basic.htm');
600 $this->netscapeBookmarkUtils
->import($post, $files);
601 $history = $this->history
->getHistory();
602 $this->assertEquals(1, count($history));
603 $this->assertEquals(History
::IMPORT
, $history[0]['event']);
604 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
606 // re-import as private, enable overwriting
607 $this->netscapeBookmarkUtils
->import($post, $files);
608 $history = $this->history
->getHistory();
609 $this->assertEquals(2, count($history));
610 $this->assertEquals(History
::IMPORT
, $history[0]['event']);
611 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
612 $this->assertEquals(History
::IMPORT
, $history[1]['event']);
613 $this->assertTrue(new DateTime('-5 seconds') < $history[1]['datetime']);