aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/netscape
diff options
context:
space:
mode:
Diffstat (limited to 'tests/netscape')
-rw-r--r--tests/netscape/BookmarkExportTest.php69
-rw-r--r--tests/netscape/BookmarkImportTest.php68
2 files changed, 82 insertions, 55 deletions
diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php
index 6c948bba..509da51d 100644
--- a/tests/netscape/BookmarkExportTest.php
+++ b/tests/netscape/BookmarkExportTest.php
@@ -1,11 +1,12 @@
1<?php 1<?php
2
2namespace Shaarli\Netscape; 3namespace Shaarli\Netscape;
3 4
5use PHPUnit\Framework\TestCase;
4use Shaarli\Bookmark\BookmarkFileService; 6use Shaarli\Bookmark\BookmarkFileService;
5use Shaarli\Bookmark\LinkDB;
6use Shaarli\Config\ConfigManager; 7use Shaarli\Config\ConfigManager;
7use Shaarli\Formatter\FormatterFactory;
8use Shaarli\Formatter\BookmarkFormatter; 8use Shaarli\Formatter\BookmarkFormatter;
9use Shaarli\Formatter\FormatterFactory;
9use Shaarli\History; 10use Shaarli\History;
10 11
11require_once 'tests/utils/ReferenceLinkDB.php'; 12require_once 'tests/utils/ReferenceLinkDB.php';
@@ -13,7 +14,7 @@ require_once 'tests/utils/ReferenceLinkDB.php';
13/** 14/**
14 * Netscape bookmark export 15 * Netscape bookmark export
15 */ 16 */
16class BookmarkExportTest extends \PHPUnit\Framework\TestCase 17class BookmarkExportTest extends TestCase
17{ 18{
18 /** 19 /**
19 * @var string datastore to test write operations 20 * @var string datastore to test write operations
@@ -21,6 +22,11 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
21 protected static $testDatastore = 'sandbox/datastore.php'; 22 protected static $testDatastore = 'sandbox/datastore.php';
22 23
23 /** 24 /**
25 * @var ConfigManager instance.
26 */
27 protected static $conf;
28
29 /**
24 * @var \ReferenceLinkDB instance. 30 * @var \ReferenceLinkDB instance.
25 */ 31 */
26 protected static $refDb = null; 32 protected static $refDb = null;
@@ -36,18 +42,37 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
36 protected static $formatter; 42 protected static $formatter;
37 43
38 /** 44 /**
45 * @var History instance
46 */
47 protected static $history;
48
49 /**
50 * @var NetscapeBookmarkUtils
51 */
52 protected $netscapeBookmarkUtils;
53
54 /**
39 * Instantiate reference data 55 * Instantiate reference data
40 */ 56 */
41 public static function setUpBeforeClass() 57 public static function setUpBeforeClass()
42 { 58 {
43 $conf = new ConfigManager('tests/utils/config/configJson'); 59 static::$conf = new ConfigManager('tests/utils/config/configJson');
44 $conf->set('resource.datastore', self::$testDatastore); 60 static::$conf->set('resource.datastore', static::$testDatastore);
45 self::$refDb = new \ReferenceLinkDB(); 61 static::$refDb = new \ReferenceLinkDB();
46 self::$refDb->write(self::$testDatastore); 62 static::$refDb->write(static::$testDatastore);
47 $history = new History('sandbox/history.php'); 63 static::$history = new History('sandbox/history.php');
48 self::$bookmarkService = new BookmarkFileService($conf, $history, true); 64 static::$bookmarkService = new BookmarkFileService(static::$conf, static::$history, true);
49 $factory = new FormatterFactory($conf, true); 65 $factory = new FormatterFactory(static::$conf, true);
50 self::$formatter = $factory->getFormatter('raw'); 66 static::$formatter = $factory->getFormatter('raw');
67 }
68
69 public function setUp(): void
70 {
71 $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils(
72 static::$bookmarkService,
73 static::$conf,
74 static::$history
75 );
51 } 76 }
52 77
53 /** 78 /**
@@ -57,8 +82,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
57 */ 82 */
58 public function testFilterAndFormatInvalid() 83 public function testFilterAndFormatInvalid()
59 { 84 {
60 NetscapeBookmarkUtils::filterAndFormat( 85 $this->netscapeBookmarkUtils->filterAndFormat(
61 self::$bookmarkService,
62 self::$formatter, 86 self::$formatter,
63 'derp', 87 'derp',
64 false, 88 false,
@@ -71,8 +95,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
71 */ 95 */
72 public function testFilterAndFormatAll() 96 public function testFilterAndFormatAll()
73 { 97 {
74 $links = NetscapeBookmarkUtils::filterAndFormat( 98 $links = $this->netscapeBookmarkUtils->filterAndFormat(
75 self::$bookmarkService,
76 self::$formatter, 99 self::$formatter,
77 'all', 100 'all',
78 false, 101 false,
@@ -97,8 +120,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
97 */ 120 */
98 public function testFilterAndFormatPrivate() 121 public function testFilterAndFormatPrivate()
99 { 122 {
100 $links = NetscapeBookmarkUtils::filterAndFormat( 123 $links = $this->netscapeBookmarkUtils->filterAndFormat(
101 self::$bookmarkService,
102 self::$formatter, 124 self::$formatter,
103 'private', 125 'private',
104 false, 126 false,
@@ -123,8 +145,7 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
123 */ 145 */
124 public function testFilterAndFormatPublic() 146 public function testFilterAndFormatPublic()
125 { 147 {
126 $links = NetscapeBookmarkUtils::filterAndFormat( 148 $links = $this->netscapeBookmarkUtils->filterAndFormat(
127 self::$bookmarkService,
128 self::$formatter, 149 self::$formatter,
129 'public', 150 'public',
130 false, 151 false,
@@ -149,15 +170,14 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
149 */ 170 */
150 public function testFilterAndFormatDoNotPrependNoteUrl() 171 public function testFilterAndFormatDoNotPrependNoteUrl()
151 { 172 {
152 $links = NetscapeBookmarkUtils::filterAndFormat( 173 $links = $this->netscapeBookmarkUtils->filterAndFormat(
153 self::$bookmarkService,
154 self::$formatter, 174 self::$formatter,
155 'public', 175 'public',
156 false, 176 false,
157 '' 177 ''
158 ); 178 );
159 $this->assertEquals( 179 $this->assertEquals(
160 '?WDWyig', 180 '/shaare/WDWyig',
161 $links[2]['url'] 181 $links[2]['url']
162 ); 182 );
163 } 183 }
@@ -168,15 +188,14 @@ class BookmarkExportTest extends \PHPUnit\Framework\TestCase
168 public function testFilterAndFormatPrependNoteUrl() 188 public function testFilterAndFormatPrependNoteUrl()
169 { 189 {
170 $indexUrl = 'http://localhost:7469/shaarli/'; 190 $indexUrl = 'http://localhost:7469/shaarli/';
171 $links = NetscapeBookmarkUtils::filterAndFormat( 191 $links = $this->netscapeBookmarkUtils->filterAndFormat(
172 self::$bookmarkService,
173 self::$formatter, 192 self::$formatter,
174 'public', 193 'public',
175 true, 194 true,
176 $indexUrl 195 $indexUrl
177 ); 196 );
178 $this->assertEquals( 197 $this->assertEquals(
179 $indexUrl . '?WDWyig', 198 $indexUrl . 'shaare/WDWyig',
180 $links[2]['url'] 199 $links[2]['url']
181 ); 200 );
182 } 201 }
diff --git a/tests/netscape/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php
index fef7f6d1..f678e26b 100644
--- a/tests/netscape/BookmarkImportTest.php
+++ b/tests/netscape/BookmarkImportTest.php
@@ -1,29 +1,31 @@
1<?php 1<?php
2
2namespace Shaarli\Netscape; 3namespace Shaarli\Netscape;
3 4
4use DateTime; 5use DateTime;
6use PHPUnit\Framework\TestCase;
7use Psr\Http\Message\UploadedFileInterface;
5use Shaarli\Bookmark\Bookmark; 8use Shaarli\Bookmark\Bookmark;
6use Shaarli\Bookmark\BookmarkFilter;
7use Shaarli\Bookmark\BookmarkFileService; 9use Shaarli\Bookmark\BookmarkFileService;
8use Shaarli\Bookmark\LinkDB; 10use Shaarli\Bookmark\BookmarkFilter;
9use Shaarli\Config\ConfigManager; 11use Shaarli\Config\ConfigManager;
10use Shaarli\History; 12use Shaarli\History;
13use Slim\Http\UploadedFile;
11 14
12/** 15/**
13 * Utility function to load a file's metadata in a $_FILES-like array 16 * Utility function to load a file's metadata in a $_FILES-like array
14 * 17 *
15 * @param string $filename Basename of the file 18 * @param string $filename Basename of the file
16 * 19 *
17 * @return array A $_FILES-like array 20 * @return UploadedFileInterface Upload file in PSR-7 compatible object
18 */ 21 */
19function file2array($filename) 22function file2array($filename)
20{ 23{
21 return array( 24 return new UploadedFile(
22 'filetoupload' => array( 25 __DIR__ . '/input/' . $filename,
23 'name' => $filename, 26 $filename,
24 'tmp_name' => __DIR__ . '/input/' . $filename, 27 null,
25 'size' => filesize(__DIR__ . '/input/' . $filename) 28 filesize(__DIR__ . '/input/' . $filename)
26 )
27 ); 29 );
28} 30}
29 31
@@ -31,7 +33,7 @@ function file2array($filename)
31/** 33/**
32 * Netscape bookmark import 34 * Netscape bookmark import
33 */ 35 */
34class BookmarkImportTest extends \PHPUnit\Framework\TestCase 36class BookmarkImportTest extends TestCase
35{ 37{
36 /** 38 /**
37 * @var string datastore to test write operations 39 * @var string datastore to test write operations
@@ -64,6 +66,11 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
64 protected $history; 66 protected $history;
65 67
66 /** 68 /**
69 * @var NetscapeBookmarkUtils
70 */
71 protected $netscapeBookmarkUtils;
72
73 /**
67 * @var string Save the current timezone. 74 * @var string Save the current timezone.
68 */ 75 */
69 protected static $defaultTimeZone; 76 protected static $defaultTimeZone;
@@ -91,6 +98,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
91 $this->conf->set('resource.datastore', self::$testDatastore); 98 $this->conf->set('resource.datastore', self::$testDatastore);
92 $this->history = new History(self::$historyFilePath); 99 $this->history = new History(self::$historyFilePath);
93 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); 100 $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true);
101 $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history);
94 } 102 }
95 103
96 /** 104 /**
@@ -115,7 +123,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
115 $this->assertEquals( 123 $this->assertEquals(
116 'File empty.htm (0 bytes) has an unknown file format.' 124 'File empty.htm (0 bytes) has an unknown file format.'
117 .' Nothing was imported.', 125 .' Nothing was imported.',
118 NetscapeBookmarkUtils::import(null, $files, null, $this->conf, $this->history) 126 $this->netscapeBookmarkUtils->import(null, $files)
119 ); 127 );
120 $this->assertEquals(0, $this->bookmarkService->count()); 128 $this->assertEquals(0, $this->bookmarkService->count());
121 } 129 }
@@ -128,7 +136,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
128 $files = file2array('no_doctype.htm'); 136 $files = file2array('no_doctype.htm');
129 $this->assertEquals( 137 $this->assertEquals(
130 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', 138 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.',
131 NetscapeBookmarkUtils::import(null, $files, null, $this->conf, $this->history) 139 $this->netscapeBookmarkUtils->import(null, $files)
132 ); 140 );
133 $this->assertEquals(0, $this->bookmarkService->count()); 141 $this->assertEquals(0, $this->bookmarkService->count());
134 } 142 }
@@ -142,7 +150,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
142 $this->assertStringMatchesFormat( 150 $this->assertStringMatchesFormat(
143 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:' 151 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:'
144 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 152 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
145 NetscapeBookmarkUtils::import(null, $files, $this->bookmarkService, $this->conf, $this->history) 153 $this->netscapeBookmarkUtils->import(null, $files)
146 ); 154 );
147 $this->assertEquals(2, $this->bookmarkService->count()); 155 $this->assertEquals(2, $this->bookmarkService->count());
148 } 156 }
@@ -157,7 +165,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
157 $this->assertStringMatchesFormat( 165 $this->assertStringMatchesFormat(
158 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:' 166 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
159 .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 167 .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
160 NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) 168 $this->netscapeBookmarkUtils->import([], $files)
161 ); 169 );
162 $this->assertEquals(1, $this->bookmarkService->count()); 170 $this->assertEquals(1, $this->bookmarkService->count());
163 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 171 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -185,7 +193,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
185 $this->assertStringMatchesFormat( 193 $this->assertStringMatchesFormat(
186 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:' 194 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
187 .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 195 .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
188 NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) 196 $this->netscapeBookmarkUtils->import([], $files)
189 ); 197 );
190 $this->assertEquals(8, $this->bookmarkService->count()); 198 $this->assertEquals(8, $this->bookmarkService->count());
191 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 199 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -306,7 +314,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
306 $this->assertStringMatchesFormat( 314 $this->assertStringMatchesFormat(
307 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 315 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
308 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 316 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
309 NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) 317 $this->netscapeBookmarkUtils->import([], $files)
310 ); 318 );
311 319
312 $this->assertEquals(2, $this->bookmarkService->count()); 320 $this->assertEquals(2, $this->bookmarkService->count());
@@ -349,7 +357,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
349 $this->assertStringMatchesFormat( 357 $this->assertStringMatchesFormat(
350 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 358 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
351 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 359 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
352 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 360 $this->netscapeBookmarkUtils->import($post, $files)
353 ); 361 );
354 362
355 $this->assertEquals(2, $this->bookmarkService->count()); 363 $this->assertEquals(2, $this->bookmarkService->count());
@@ -392,7 +400,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
392 $this->assertStringMatchesFormat( 400 $this->assertStringMatchesFormat(
393 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 401 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
394 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 402 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
395 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 403 $this->netscapeBookmarkUtils->import($post, $files)
396 ); 404 );
397 $this->assertEquals(2, $this->bookmarkService->count()); 405 $this->assertEquals(2, $this->bookmarkService->count());
398 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 406 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -410,7 +418,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
410 $this->assertStringMatchesFormat( 418 $this->assertStringMatchesFormat(
411 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 419 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
412 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 420 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
413 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 421 $this->netscapeBookmarkUtils->import($post, $files)
414 ); 422 );
415 $this->assertEquals(2, $this->bookmarkService->count()); 423 $this->assertEquals(2, $this->bookmarkService->count());
416 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 424 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -430,7 +438,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
430 $this->assertStringMatchesFormat( 438 $this->assertStringMatchesFormat(
431 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 439 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
432 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 440 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
433 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 441 $this->netscapeBookmarkUtils->import($post, $files)
434 ); 442 );
435 $this->assertEquals(2, $this->bookmarkService->count()); 443 $this->assertEquals(2, $this->bookmarkService->count());
436 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 444 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -445,7 +453,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
445 $this->assertStringMatchesFormat( 453 $this->assertStringMatchesFormat(
446 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 454 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
447 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', 455 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
448 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 456 $this->netscapeBookmarkUtils->import($post, $files)
449 ); 457 );
450 $this->assertEquals(2, $this->bookmarkService->count()); 458 $this->assertEquals(2, $this->bookmarkService->count());
451 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 459 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -465,7 +473,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
465 $this->assertStringMatchesFormat( 473 $this->assertStringMatchesFormat(
466 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 474 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
467 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 475 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
468 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 476 $this->netscapeBookmarkUtils->import($post, $files)
469 ); 477 );
470 $this->assertEquals(2, $this->bookmarkService->count()); 478 $this->assertEquals(2, $this->bookmarkService->count());
471 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 479 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -480,7 +488,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
480 $this->assertStringMatchesFormat( 488 $this->assertStringMatchesFormat(
481 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 489 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
482 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', 490 .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
483 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 491 $this->netscapeBookmarkUtils->import($post, $files)
484 ); 492 );
485 $this->assertEquals(2, $this->bookmarkService->count()); 493 $this->assertEquals(2, $this->bookmarkService->count());
486 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 494 $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -498,7 +506,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
498 $this->assertStringMatchesFormat( 506 $this->assertStringMatchesFormat(
499 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 507 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
500 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 508 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
501 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 509 $this->netscapeBookmarkUtils->import($post, $files)
502 ); 510 );
503 $this->assertEquals(2, $this->bookmarkService->count()); 511 $this->assertEquals(2, $this->bookmarkService->count());
504 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 512 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -508,7 +516,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
508 $this->assertStringMatchesFormat( 516 $this->assertStringMatchesFormat(
509 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 517 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
510 .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.', 518 .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.',
511 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 519 $this->netscapeBookmarkUtils->import($post, $files)
512 ); 520 );
513 $this->assertEquals(2, $this->bookmarkService->count()); 521 $this->assertEquals(2, $this->bookmarkService->count());
514 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 522 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -527,7 +535,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
527 $this->assertStringMatchesFormat( 535 $this->assertStringMatchesFormat(
528 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 536 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
529 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 537 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
530 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 538 $this->netscapeBookmarkUtils->import($post, $files)
531 ); 539 );
532 $this->assertEquals(2, $this->bookmarkService->count()); 540 $this->assertEquals(2, $this->bookmarkService->count());
533 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 541 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -548,7 +556,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
548 $this->assertStringMatchesFormat( 556 $this->assertStringMatchesFormat(
549 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' 557 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
550 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 558 .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
551 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) 559 $this->netscapeBookmarkUtils->import($post, $files)
552 ); 560 );
553 $this->assertEquals(2, $this->bookmarkService->count()); 561 $this->assertEquals(2, $this->bookmarkService->count());
554 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 562 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -573,7 +581,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
573 $this->assertStringMatchesFormat( 581 $this->assertStringMatchesFormat(
574 'File same_date.htm (453 bytes) was successfully processed in %d seconds:' 582 'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
575 .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', 583 .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
576 NetscapeBookmarkUtils::import(array(), $files, $this->bookmarkService, $this->conf, $this->history) 584 $this->netscapeBookmarkUtils->import(array(), $files)
577 ); 585 );
578 $this->assertEquals(3, $this->bookmarkService->count()); 586 $this->assertEquals(3, $this->bookmarkService->count());
579 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); 587 $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
@@ -589,14 +597,14 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase
589 'overwrite' => 'true', 597 'overwrite' => 'true',
590 ]; 598 ];
591 $files = file2array('netscape_basic.htm'); 599 $files = file2array('netscape_basic.htm');
592 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history); 600 $this->netscapeBookmarkUtils->import($post, $files);
593 $history = $this->history->getHistory(); 601 $history = $this->history->getHistory();
594 $this->assertEquals(1, count($history)); 602 $this->assertEquals(1, count($history));
595 $this->assertEquals(History::IMPORT, $history[0]['event']); 603 $this->assertEquals(History::IMPORT, $history[0]['event']);
596 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']); 604 $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']);
597 605
598 // re-import as private, enable overwriting 606 // re-import as private, enable overwriting
599 NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history); 607 $this->netscapeBookmarkUtils->import($post, $files);
600 $history = $this->history->getHistory(); 608 $history = $this->history->getHistory();
601 $this->assertEquals(2, count($history)); 609 $this->assertEquals(2, count($history));
602 $this->assertEquals(History::IMPORT, $history[0]['event']); 610 $this->assertEquals(History::IMPORT, $history[0]['event']);