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