3 namespace Shaarli\Netscape
;
6 use PHPUnit\Framework\TestCase
;
7 use Shaarli\Bookmark\Bookmark
;
8 use Shaarli\Bookmark\BookmarkFileService
;
9 use Shaarli\Bookmark\BookmarkFilter
;
10 use Shaarli\Config\ConfigManager
;
14 * Utility function to load a file's metadata in a $_FILES-like array
16 * @param string $filename Basename of the file
18 * @return array A $_FILES-like array
20 function file2array($filename)
23 'filetoupload' => array(
25 'tmp_name' => __DIR__
. '/input/' . $filename,
26 'size' => filesize(__DIR__
. '/input/' . $filename)
33 * Netscape bookmark import
35 class BookmarkImportTest
extends TestCase
38 * @var string datastore to test write operations
40 protected static $testDatastore = 'sandbox/datastore.php';
43 * @var string History file path
45 protected static $historyFilePath = 'sandbox/history.php';
48 * @var BookmarkFileService private LinkDB instance
50 protected $bookmarkService = null;
53 * @var string Dummy page cache
55 protected $pagecache = 'tests';
58 * @var ConfigManager instance.
63 * @var History instance.
68 * @var NetscapeBookmarkUtils
70 protected $netscapeBookmarkUtils;
73 * @var string Save the current timezone.
75 protected static $defaultTimeZone;
77 public static function setUpBeforeClass()
79 self
::$defaultTimeZone = date_default_timezone_get();
80 // Timezone without DST for test consistency
81 date_default_timezone_set('Africa/Nairobi');
85 * Resets test data before each test
87 protected function setUp()
89 if (file_exists(self
::$testDatastore)) {
90 unlink(self
::$testDatastore);
92 // start with an empty datastore
93 file_put_contents(self
::$testDatastore, '<?php /* S7QysKquBQA= */ ?>');
95 $this->conf
= new ConfigManager('tests/utils/config/configJson');
96 $this->conf
->set('resource.page_cache', $this->pagecache
);
97 $this->conf
->set('resource.datastore', self
::$testDatastore);
98 $this->history
= new History(self
::$historyFilePath);
99 $this->bookmarkService
= new BookmarkFileService($this->conf
, $this->history
, true);
100 $this->netscapeBookmarkUtils
= new NetscapeBookmarkUtils($this->bookmarkService
, $this->conf
, $this->history
);
104 * Delete history file.
106 public function tearDown()
108 @unlink(self
::$historyFilePath);
111 public static function tearDownAfterClass()
113 date_default_timezone_set(self
::$defaultTimeZone);
117 * Attempt to import bookmarks from an empty file
119 public function testImportEmptyData()
121 $files = file2array('empty.htm');
123 'File empty.htm (0 bytes) has an unknown file format.'
124 .' Nothing was imported.',
125 $this->netscapeBookmarkUtils
->import(null, $files)
127 $this->assertEquals(0, $this->bookmarkService
->count());
131 * Attempt to import bookmarks from a file with no Doctype
133 public function testImportNoDoctype()
135 $files = file2array('no_doctype.htm');
137 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.',
138 $this->netscapeBookmarkUtils
->import(null, $files)
140 $this->assertEquals(0, $this->bookmarkService
->count());
144 * Attempt to import bookmarks from a file with a lowercase Doctype
146 public function testImportLowecaseDoctype()
148 $files = file2array('lowercase_doctype.htm');
149 $this->assertStringMatchesFormat(
150 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:'
151 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
152 $this->netscapeBookmarkUtils
->import(null, $files)
154 $this->assertEquals(2, $this->bookmarkService
->count());
159 * Ensure IE dumps are supported
161 public function testImportInternetExplorerEncoding()
163 $files = file2array('internet_explorer_encoding.htm');
164 $this->assertStringMatchesFormat(
165 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
166 .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
167 $this->netscapeBookmarkUtils
->import([], $files)
169 $this->assertEquals(1, $this->bookmarkService
->count());
170 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
172 $bookmark = $this->bookmarkService
->findByUrl('http://hginit.com/');
173 $this->assertEquals(0, $bookmark->getId());
175 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160618_203944'),
176 $bookmark->getCreated()
178 $this->assertEquals('Hg Init a Mercurial tutorial by Joel Spolsky', $bookmark->getTitle());
179 $this->assertEquals('http://hginit.com/', $bookmark->getUrl());
180 $this->assertEquals('', $bookmark->getDescription());
181 $this->assertFalse($bookmark->isPrivate());
182 $this->assertEquals('', $bookmark->getTagsString());
183 $this->assertEquals('La37cg', $bookmark->getShortUrl());
187 * Import bookmarks nested in a folder hierarchy
189 public function testImportNested()
191 $files = file2array('netscape_nested.htm');
192 $this->assertStringMatchesFormat(
193 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
194 .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
195 $this->netscapeBookmarkUtils
->import([], $files)
197 $this->assertEquals(8, $this->bookmarkService
->count());
198 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
200 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1');
201 $this->assertEquals(0, $bookmark->getId());
203 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235541'),
204 $bookmark->getCreated()
206 $this->assertEquals('Nested 1', $bookmark->getTitle());
207 $this->assertEquals('http://nest.ed/1', $bookmark->getUrl());
208 $this->assertEquals('', $bookmark->getDescription());
209 $this->assertFalse($bookmark->isPrivate());
210 $this->assertEquals('tag1 tag2', $bookmark->getTagsString());
211 $this->assertEquals('KyDNKA', $bookmark->getShortUrl());
213 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1-1');
214 $this->assertEquals(1, $bookmark->getId());
216 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235542'),
217 $bookmark->getCreated()
219 $this->assertEquals('Nested 1-1', $bookmark->getTitle());
220 $this->assertEquals('http://nest.ed/1-1', $bookmark->getUrl());
221 $this->assertEquals('', $bookmark->getDescription());
222 $this->assertFalse($bookmark->isPrivate());
223 $this->assertEquals('folder1 tag1 tag2', $bookmark->getTagsString());
224 $this->assertEquals('T2LnXg', $bookmark->getShortUrl());
226 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/1-2');
227 $this->assertEquals(2, $bookmark->getId());
229 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235547'),
230 $bookmark->getCreated()
232 $this->assertEquals('Nested 1-2', $bookmark->getTitle());
233 $this->assertEquals('http://nest.ed/1-2', $bookmark->getUrl());
234 $this->assertEquals('', $bookmark->getDescription());
235 $this->assertFalse($bookmark->isPrivate());
236 $this->assertEquals('folder1 tag3 tag4', $bookmark->getTagsString());
237 $this->assertEquals('46SZxA', $bookmark->getShortUrl());
239 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2-1');
240 $this->assertEquals(3, $bookmark->getId());
242 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160202_202222'),
243 $bookmark->getCreated()
245 $this->assertEquals('Nested 2-1', $bookmark->getTitle());
246 $this->assertEquals('http://nest.ed/2-1', $bookmark->getUrl());
247 $this->assertEquals('First link of the second section', $bookmark->getDescription());
248 $this->assertTrue($bookmark->isPrivate());
249 $this->assertEquals('folder2', $bookmark->getTagsString());
250 $this->assertEquals('4UHOSw', $bookmark->getShortUrl());
252 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2-2');
253 $this->assertEquals(4, $bookmark->getId());
255 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160119_230227'),
256 $bookmark->getCreated()
258 $this->assertEquals('Nested 2-2', $bookmark->getTitle());
259 $this->assertEquals('http://nest.ed/2-2', $bookmark->getUrl());
260 $this->assertEquals('Second link of the second section', $bookmark->getDescription());
261 $this->assertTrue($bookmark->isPrivate());
262 $this->assertEquals('folder2', $bookmark->getTagsString());
263 $this->assertEquals('yfzwbw', $bookmark->getShortUrl());
265 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/3-1');
266 $this->assertEquals(5, $bookmark->getId());
268 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160202_202222'),
269 $bookmark->getCreated()
271 $this->assertEquals('Nested 3-1', $bookmark->getTitle());
272 $this->assertEquals('http://nest.ed/3-1', $bookmark->getUrl());
273 $this->assertEquals('', $bookmark->getDescription());
274 $this->assertFalse($bookmark->isPrivate());
275 $this->assertEquals('folder3 folder3-1 tag3', $bookmark->getTagsString());
276 $this->assertEquals('UwxIUQ', $bookmark->getShortUrl());
278 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/3-2');
279 $this->assertEquals(6, $bookmark->getId());
281 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160119_230227'),
282 $bookmark->getCreated()
284 $this->assertEquals('Nested 3-2', $bookmark->getTitle());
285 $this->assertEquals('http://nest.ed/3-2', $bookmark->getUrl());
286 $this->assertEquals('', $bookmark->getDescription());
287 $this->assertFalse($bookmark->isPrivate());
288 $this->assertEquals('folder3 folder3-1', $bookmark->getTagsString());
289 $this->assertEquals('p8dyZg', $bookmark->getShortUrl());
291 $bookmark = $this->bookmarkService
->findByUrl('http://nest.ed/2');
292 $this->assertEquals(7, $bookmark->getId());
294 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160229_111541'),
295 $bookmark->getCreated()
297 $this->assertEquals('Nested 2', $bookmark->getTitle());
298 $this->assertEquals('http://nest.ed/2', $bookmark->getUrl());
299 $this->assertEquals('', $bookmark->getDescription());
300 $this->assertFalse($bookmark->isPrivate());
301 $this->assertEquals('tag4', $bookmark->getTagsString());
302 $this->assertEquals('Gt3Uug', $bookmark->getShortUrl());
306 * Import bookmarks with the default privacy setting (reuse from file)
308 * The $_POST array is not set.
310 public function testImportDefaultPrivacyNoPost()
312 $files = file2array('netscape_basic.htm');
313 $this->assertStringMatchesFormat(
314 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
315 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
316 $this->netscapeBookmarkUtils
->import([], $files)
319 $this->assertEquals(2, $this->bookmarkService
->count());
320 $this->assertEquals(1, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
322 $bookmark = $this->bookmarkService
->findByUrl('https://private.tld');
323 $this->assertEquals(0, $bookmark->getId());
325 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20001010_135536'),
326 $bookmark->getCreated()
328 $this->assertEquals('Secret stuff', $bookmark->getTitle());
329 $this->assertEquals('https://private.tld', $bookmark->getUrl());
330 $this->assertEquals('Super-secret stuff you\'re not supposed to know about', $bookmark->getDescription());
331 $this->assertTrue($bookmark->isPrivate());
332 $this->assertEquals('private secret', $bookmark->getTagsString());
333 $this->assertEquals('EokDtA', $bookmark->getShortUrl());
335 $bookmark = $this->bookmarkService
->findByUrl('http://public.tld');
336 $this->assertEquals(1, $bookmark->getId());
338 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235548'),
339 $bookmark->getCreated()
341 $this->assertEquals('Public stuff', $bookmark->getTitle());
342 $this->assertEquals('http://public.tld', $bookmark->getUrl());
343 $this->assertEquals('', $bookmark->getDescription());
344 $this->assertFalse($bookmark->isPrivate());
345 $this->assertEquals('public hello world', $bookmark->getTagsString());
346 $this->assertEquals('Er9ddA', $bookmark->getShortUrl());
350 * Import bookmarks with the default privacy setting (reuse from file)
352 public function testImportKeepPrivacy()
354 $post = array('privacy' => 'default');
355 $files = file2array('netscape_basic.htm');
356 $this->assertStringMatchesFormat(
357 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
358 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
359 $this->netscapeBookmarkUtils
->import($post, $files)
362 $this->assertEquals(2, $this->bookmarkService
->count());
363 $this->assertEquals(1, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
365 $bookmark = $this->bookmarkService
->findByUrl('https://private.tld');
366 $this->assertEquals(0, $bookmark->getId());
368 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20001010_135536'),
369 $bookmark->getCreated()
371 $this->assertEquals('Secret stuff', $bookmark->getTitle());
372 $this->assertEquals('https://private.tld', $bookmark->getUrl());
373 $this->assertEquals('Super-secret stuff you\'re not supposed to know about', $bookmark->getDescription());
374 $this->assertTrue($bookmark->isPrivate());
375 $this->assertEquals('private secret', $bookmark->getTagsString());
376 $this->assertEquals('EokDtA', $bookmark->getShortUrl());
378 $bookmark = $this->bookmarkService
->findByUrl('http://public.tld');
379 $this->assertEquals(1, $bookmark->getId());
381 DateTime
::createFromFormat(Bookmark
::LINK_DATE_FORMAT
, '20160225_235548'),
382 $bookmark->getCreated()
384 $this->assertEquals('Public stuff', $bookmark->getTitle());
385 $this->assertEquals('http://public.tld', $bookmark->getUrl());
386 $this->assertEquals('', $bookmark->getDescription());
387 $this->assertFalse($bookmark->isPrivate());
388 $this->assertEquals('public hello world', $bookmark->getTagsString());
389 $this->assertEquals('Er9ddA', $bookmark->getShortUrl());
393 * Import bookmarks as public
395 public function testImportAsPublic()
397 $post = array('privacy' => 'public');
398 $files = file2array('netscape_basic.htm');
399 $this->assertStringMatchesFormat(
400 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
401 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
402 $this->netscapeBookmarkUtils
->import($post, $files)
404 $this->assertEquals(2, $this->bookmarkService
->count());
405 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
406 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
407 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
411 * Import bookmarks as private
413 public function testImportAsPrivate()
415 $post = array('privacy' => 'private');
416 $files = file2array('netscape_basic.htm');
417 $this->assertStringMatchesFormat(
418 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
419 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
420 $this->netscapeBookmarkUtils
->import($post, $files)
422 $this->assertEquals(2, $this->bookmarkService
->count());
423 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
424 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
425 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
429 * Overwrite private bookmarks so they become public
431 public function testOverwriteAsPublic()
433 $files = file2array('netscape_basic.htm');
435 // import bookmarks as private
436 $post = array('privacy' => 'private');
437 $this->assertStringMatchesFormat(
438 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
439 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
440 $this->netscapeBookmarkUtils
->import($post, $files)
442 $this->assertEquals(2, $this->bookmarkService
->count());
443 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
444 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
445 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
447 // re-import as public, enable overwriting
449 'privacy' => 'public',
450 'overwrite' => 'true'
452 $this->assertStringMatchesFormat(
453 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
454 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
455 $this->netscapeBookmarkUtils
->import($post, $files)
457 $this->assertEquals(2, $this->bookmarkService
->count());
458 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
459 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
460 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
464 * Overwrite public bookmarks so they become private
466 public function testOverwriteAsPrivate()
468 $files = file2array('netscape_basic.htm');
470 // import bookmarks as public
471 $post = array('privacy' => 'public');
472 $this->assertStringMatchesFormat(
473 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
474 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
475 $this->netscapeBookmarkUtils
->import($post, $files)
477 $this->assertEquals(2, $this->bookmarkService
->count());
478 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
479 $this->assertFalse($this->bookmarkService
->get(0)->isPrivate());
480 $this->assertFalse($this->bookmarkService
->get(1)->isPrivate());
482 // re-import as private, enable overwriting
484 'privacy' => 'private',
485 'overwrite' => 'true'
487 $this->assertStringMatchesFormat(
488 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
489 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
490 $this->netscapeBookmarkUtils
->import($post, $files)
492 $this->assertEquals(2, $this->bookmarkService
->count());
493 $this->assertEquals(2, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
494 $this->assertTrue($this->bookmarkService
->get(0)->isPrivate());
495 $this->assertTrue($this->bookmarkService
->get(1)->isPrivate());
499 * Attept to import the same bookmarks twice without enabling overwriting
501 public function testSkipOverwrite()
503 $post = array('privacy' => 'public');
504 $files = file2array('netscape_basic.htm');
505 $this->assertStringMatchesFormat(
506 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
507 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
508 $this->netscapeBookmarkUtils
->import($post, $files)
510 $this->assertEquals(2, $this->bookmarkService
->count());
511 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
513 // re-import as private, DO NOT enable overwriting
514 $post = array('privacy' => 'private');
515 $this->assertStringMatchesFormat(
516 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
517 .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.',
518 $this->netscapeBookmarkUtils
->import($post, $files)
520 $this->assertEquals(2, $this->bookmarkService
->count());
521 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
525 * Add user-specified tags to all imported bookmarks
527 public function testSetDefaultTags()
530 'privacy' => 'public',
531 'default_tags' => 'tag1,tag2 tag3'
533 $files = file2array('netscape_basic.htm');
534 $this->assertStringMatchesFormat(
535 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
536 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
537 $this->netscapeBookmarkUtils
->import($post, $files)
539 $this->assertEquals(2, $this->bookmarkService
->count());
540 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
541 $this->assertEquals('tag1 tag2 tag3 private secret', $this->bookmarkService
->get(0)->getTagsString());
542 $this->assertEquals('tag1 tag2 tag3 public hello world', $this->bookmarkService
->get(1)->getTagsString());
546 * The user-specified tags contain characters to be escaped
548 public function testSanitizeDefaultTags()
551 'privacy' => 'public',
552 'default_tags' => 'tag1&,tag2 "tag3"'
554 $files = file2array('netscape_basic.htm');
555 $this->assertStringMatchesFormat(
556 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
557 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
558 $this->netscapeBookmarkUtils
->import($post, $files)
560 $this->assertEquals(2, $this->bookmarkService
->count());
561 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
563 'tag1& tag2 "tag3" private secret',
564 $this->bookmarkService
->get(0)->getTagsString()
567 'tag1& tag2 "tag3" public hello world',
568 $this->bookmarkService
->get(1)->getTagsString()
573 * Ensure each imported bookmark has a unique id
575 * See https://github.com/shaarli/Shaarli/issues/351
577 public function testImportSameDate()
579 $files = file2array('same_date.htm');
580 $this->assertStringMatchesFormat(
581 'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
582 .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
583 $this->netscapeBookmarkUtils
->import(array(), $files)
585 $this->assertEquals(3, $this->bookmarkService
->count());
586 $this->assertEquals(0, $this->bookmarkService
->count(BookmarkFilter
::$PRIVATE));
587 $this->assertEquals(0, $this->bookmarkService
->get(0)->getId());
588 $this->assertEquals(1, $this->bookmarkService
->get(1)->getId());
589 $this->assertEquals(2, $this->bookmarkService
->get(2)->getId());
592 public function testImportCreateUpdateHistory()
595 'privacy' => 'public',
596 'overwrite' => 'true',
598 $files = file2array('netscape_basic.htm');
599 $this->netscapeBookmarkUtils
->import($post, $files);
600 $history = $this->history
->getHistory();
601 $this->assertEquals(1, count($history));
602 $this->assertEquals(History
::IMPORT
, $history[0]['event']);
603 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
605 // re-import as private, enable overwriting
606 $this->netscapeBookmarkUtils
->import($post, $files);
607 $history = $this->history
->getHistory();
608 $this->assertEquals(2, count($history));
609 $this->assertEquals(History
::IMPORT
, $history[0]['event']);
610 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
611 $this->assertEquals(History
::IMPORT
, $history[1]['event']);
612 $this->assertTrue(new DateTime('-5 seconds') < $history[1]['datetime']);