diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-06-17 15:55:31 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | e8a10f312a5c44314292402bb44e6ee2e71f3d5d (patch) | |
tree | 3f0c0bf3bc299eae3b379431d4a521f6904d5ee4 | |
parent | 3447d888d7881eed437117a6de2450abb96f6a76 (diff) | |
download | Shaarli-e8a10f312a5c44314292402bb44e6ee2e71f3d5d.tar.gz Shaarli-e8a10f312a5c44314292402bb44e6ee2e71f3d5d.tar.zst Shaarli-e8a10f312a5c44314292402bb44e6ee2e71f3d5d.zip |
Use NetscapeBookmarkUtils object instance instead of static calls
-rw-r--r-- | application/container/ContainerBuilder.php | 5 | ||||
-rw-r--r-- | application/container/ShaarliContainer.php | 2 | ||||
-rw-r--r-- | application/netscape/NetscapeBookmarkUtils.php | 118 | ||||
-rw-r--r-- | index.php | 9 | ||||
-rw-r--r-- | tests/netscape/BookmarkExportTest.php | 65 | ||||
-rw-r--r-- | tests/netscape/BookmarkImportTest.php | 53 |
6 files changed, 145 insertions, 107 deletions
diff --git a/application/container/ContainerBuilder.php b/application/container/ContainerBuilder.php index 72a85710..a4fd6a0c 100644 --- a/application/container/ContainerBuilder.php +++ b/application/container/ContainerBuilder.php | |||
@@ -11,6 +11,7 @@ use Shaarli\Feed\FeedBuilder; | |||
11 | use Shaarli\Formatter\FormatterFactory; | 11 | use Shaarli\Formatter\FormatterFactory; |
12 | use Shaarli\History; | 12 | use Shaarli\History; |
13 | use Shaarli\Http\HttpAccess; | 13 | use Shaarli\Http\HttpAccess; |
14 | use Shaarli\Netscape\NetscapeBookmarkUtils; | ||
14 | use Shaarli\Plugin\PluginManager; | 15 | use Shaarli\Plugin\PluginManager; |
15 | use Shaarli\Render\PageBuilder; | 16 | use Shaarli\Render\PageBuilder; |
16 | use Shaarli\Render\PageCacheManager; | 17 | use Shaarli\Render\PageCacheManager; |
@@ -118,6 +119,10 @@ class ContainerBuilder | |||
118 | return new HttpAccess(); | 119 | return new HttpAccess(); |
119 | }; | 120 | }; |
120 | 121 | ||
122 | $container['netscapeBookmarkUtils'] = function (ShaarliContainer $container): NetscapeBookmarkUtils { | ||
123 | return new NetscapeBookmarkUtils($container->bookmarkService, $container->conf, $container->history); | ||
124 | }; | ||
125 | |||
121 | return $container; | 126 | return $container; |
122 | } | 127 | } |
123 | } | 128 | } |
diff --git a/application/container/ShaarliContainer.php b/application/container/ShaarliContainer.php index 4b97aae2..b08fa4cb 100644 --- a/application/container/ShaarliContainer.php +++ b/application/container/ShaarliContainer.php | |||
@@ -10,6 +10,7 @@ use Shaarli\Feed\FeedBuilder; | |||
10 | use Shaarli\Formatter\FormatterFactory; | 10 | use Shaarli\Formatter\FormatterFactory; |
11 | use Shaarli\History; | 11 | use Shaarli\History; |
12 | use Shaarli\Http\HttpAccess; | 12 | use Shaarli\Http\HttpAccess; |
13 | use Shaarli\Netscape\NetscapeBookmarkUtils; | ||
13 | use Shaarli\Plugin\PluginManager; | 14 | use Shaarli\Plugin\PluginManager; |
14 | use Shaarli\Render\PageBuilder; | 15 | use Shaarli\Render\PageBuilder; |
15 | use Shaarli\Render\PageCacheManager; | 16 | use Shaarli\Render\PageCacheManager; |
@@ -30,6 +31,7 @@ use Slim\Container; | |||
30 | * @property History $history | 31 | * @property History $history |
31 | * @property HttpAccess $httpAccess | 32 | * @property HttpAccess $httpAccess |
32 | * @property LoginManager $loginManager | 33 | * @property LoginManager $loginManager |
34 | * @property NetscapeBookmarkUtils $netscapeBookmarkUtils | ||
33 | * @property PageBuilder $pageBuilder | 35 | * @property PageBuilder $pageBuilder |
34 | * @property PageCacheManager $pageCacheManager | 36 | * @property PageCacheManager $pageCacheManager |
35 | * @property PluginManager $pluginManager | 37 | * @property PluginManager $pluginManager |
diff --git a/application/netscape/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php index d64eef7f..8557cca2 100644 --- a/application/netscape/NetscapeBookmarkUtils.php +++ b/application/netscape/NetscapeBookmarkUtils.php | |||
@@ -16,10 +16,24 @@ use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; | |||
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Utilities to import and export bookmarks using the Netscape format | 18 | * Utilities to import and export bookmarks using the Netscape format |
19 | * TODO: Not static, use a container. | ||
20 | */ | 19 | */ |
21 | class NetscapeBookmarkUtils | 20 | class NetscapeBookmarkUtils |
22 | { | 21 | { |
22 | /** @var BookmarkServiceInterface */ | ||
23 | protected $bookmarkService; | ||
24 | |||
25 | /** @var ConfigManager */ | ||
26 | protected $conf; | ||
27 | |||
28 | /** @var History */ | ||
29 | protected $history; | ||
30 | |||
31 | public function __construct(BookmarkServiceInterface $bookmarkService, ConfigManager $conf, History $history) | ||
32 | { | ||
33 | $this->bookmarkService = $bookmarkService; | ||
34 | $this->conf = $conf; | ||
35 | $this->history = $history; | ||
36 | } | ||
23 | 37 | ||
24 | /** | 38 | /** |
25 | * Filters bookmarks and adds Netscape-formatted fields | 39 | * Filters bookmarks and adds Netscape-formatted fields |
@@ -28,18 +42,16 @@ class NetscapeBookmarkUtils | |||
28 | * - timestamp link addition date, using the Unix epoch format | 42 | * - timestamp link addition date, using the Unix epoch format |
29 | * - taglist comma-separated tag list | 43 | * - taglist comma-separated tag list |
30 | * | 44 | * |
31 | * @param BookmarkServiceInterface $bookmarkService Link datastore | ||
32 | * @param BookmarkFormatter $formatter instance | 45 | * @param BookmarkFormatter $formatter instance |
33 | * @param string $selection Which bookmarks to export: (all|private|public) | 46 | * @param string $selection Which bookmarks to export: (all|private|public) |
34 | * @param bool $prependNoteUrl Prepend note permalinks with the server's URL | 47 | * @param bool $prependNoteUrl Prepend note permalinks with the server's URL |
35 | * @param string $indexUrl Absolute URL of the Shaarli index page | 48 | * @param string $indexUrl Absolute URL of the Shaarli index page |
36 | * | 49 | * |
37 | * @return array The bookmarks to be exported, with additional fields | 50 | * @return array The bookmarks to be exported, with additional fields |
38 | *@throws Exception Invalid export selection | ||
39 | * | 51 | * |
52 | * @throws Exception Invalid export selection | ||
40 | */ | 53 | */ |
41 | public static function filterAndFormat( | 54 | public function filterAndFormat( |
42 | $bookmarkService, | ||
43 | $formatter, | 55 | $formatter, |
44 | $selection, | 56 | $selection, |
45 | $prependNoteUrl, | 57 | $prependNoteUrl, |
@@ -51,7 +63,7 @@ class NetscapeBookmarkUtils | |||
51 | } | 63 | } |
52 | 64 | ||
53 | $bookmarkLinks = array(); | 65 | $bookmarkLinks = array(); |
54 | foreach ($bookmarkService->search([], $selection) as $bookmark) { | 66 | foreach ($this->bookmarkService->search([], $selection) as $bookmark) { |
55 | $link = $formatter->format($bookmark); | 67 | $link = $formatter->format($bookmark); |
56 | $link['taglist'] = implode(',', $bookmark->getTags()); | 68 | $link['taglist'] = implode(',', $bookmark->getTags()); |
57 | if ($bookmark->isNote() && $prependNoteUrl) { | 69 | if ($bookmark->isNote() && $prependNoteUrl) { |
@@ -65,52 +77,14 @@ class NetscapeBookmarkUtils | |||
65 | } | 77 | } |
66 | 78 | ||
67 | /** | 79 | /** |
68 | * Generates an import status summary | ||
69 | * | ||
70 | * @param string $filename name of the file to import | ||
71 | * @param int $filesize size of the file to import | ||
72 | * @param int $importCount how many bookmarks were imported | ||
73 | * @param int $overwriteCount how many bookmarks were overwritten | ||
74 | * @param int $skipCount how many bookmarks were skipped | ||
75 | * @param int $duration how many seconds did the import take | ||
76 | * | ||
77 | * @return string Summary of the bookmark import status | ||
78 | */ | ||
79 | private static function importStatus( | ||
80 | $filename, | ||
81 | $filesize, | ||
82 | $importCount = 0, | ||
83 | $overwriteCount = 0, | ||
84 | $skipCount = 0, | ||
85 | $duration = 0 | ||
86 | ) { | ||
87 | $status = sprintf(t('File %s (%d bytes) '), $filename, $filesize); | ||
88 | if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) { | ||
89 | $status .= t('has an unknown file format. Nothing was imported.'); | ||
90 | } else { | ||
91 | $status .= vsprintf( | ||
92 | t( | ||
93 | 'was successfully processed in %d seconds: ' | ||
94 | . '%d bookmarks imported, %d bookmarks overwritten, %d bookmarks skipped.' | ||
95 | ), | ||
96 | [$duration, $importCount, $overwriteCount, $skipCount] | ||
97 | ); | ||
98 | } | ||
99 | return $status; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * Imports Web bookmarks from an uploaded Netscape bookmark dump | 80 | * Imports Web bookmarks from an uploaded Netscape bookmark dump |
104 | * | 81 | * |
105 | * @param array $post Server $_POST parameters | 82 | * @param array $post Server $_POST parameters |
106 | * @param array $files Server $_FILES parameters | 83 | * @param array $files Server $_FILES parameters |
107 | * @param BookmarkServiceInterface $bookmarkService Loaded LinkDB instance | ||
108 | * @param ConfigManager $conf instance | ||
109 | * @param History $history History instance | ||
110 | * | 84 | * |
111 | * @return string Summary of the bookmark import status | 85 | * @return string Summary of the bookmark import status |
112 | */ | 86 | */ |
113 | public static function import($post, $files, $bookmarkService, $conf, $history) | 87 | public function import($post, $files) |
114 | { | 88 | { |
115 | $start = time(); | 89 | $start = time(); |
116 | $filename = $files['filetoupload']['name']; | 90 | $filename = $files['filetoupload']['name']; |
@@ -141,11 +115,11 @@ class NetscapeBookmarkUtils | |||
141 | true, // nested tag support | 115 | true, // nested tag support |
142 | $defaultTags, // additional user-specified tags | 116 | $defaultTags, // additional user-specified tags |
143 | strval(1 - $defaultPrivacy), // defaultPub = 1 - defaultPrivacy | 117 | strval(1 - $defaultPrivacy), // defaultPub = 1 - defaultPrivacy |
144 | $conf->get('resource.data_dir') // log path, will be overridden | 118 | $this->conf->get('resource.data_dir') // log path, will be overridden |
145 | ); | 119 | ); |
146 | $logger = new Logger( | 120 | $logger = new Logger( |
147 | $conf->get('resource.data_dir'), | 121 | $this->conf->get('resource.data_dir'), |
148 | !$conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG, | 122 | !$this->conf->get('dev.debug') ? LogLevel::INFO : LogLevel::DEBUG, |
149 | [ | 123 | [ |
150 | 'prefix' => 'import.', | 124 | 'prefix' => 'import.', |
151 | 'extension' => 'log', | 125 | 'extension' => 'log', |
@@ -171,7 +145,7 @@ class NetscapeBookmarkUtils | |||
171 | $private = 0; | 145 | $private = 0; |
172 | } | 146 | } |
173 | 147 | ||
174 | $link = $bookmarkService->findByUrl($bkm['uri']); | 148 | $link = $this->bookmarkService->findByUrl($bkm['uri']); |
175 | $existingLink = $link !== null; | 149 | $existingLink = $link !== null; |
176 | if (! $existingLink) { | 150 | if (! $existingLink) { |
177 | $link = new Bookmark(); | 151 | $link = new Bookmark(); |
@@ -193,20 +167,21 @@ class NetscapeBookmarkUtils | |||
193 | } | 167 | } |
194 | 168 | ||
195 | $link->setTitle($bkm['title']); | 169 | $link->setTitle($bkm['title']); |
196 | $link->setUrl($bkm['uri'], $conf->get('security.allowed_protocols')); | 170 | $link->setUrl($bkm['uri'], $this->conf->get('security.allowed_protocols')); |
197 | $link->setDescription($bkm['note']); | 171 | $link->setDescription($bkm['note']); |
198 | $link->setPrivate($private); | 172 | $link->setPrivate($private); |
199 | $link->setTagsString($bkm['tags']); | 173 | $link->setTagsString($bkm['tags']); |
200 | 174 | ||
201 | $bookmarkService->addOrSet($link, false); | 175 | $this->bookmarkService->addOrSet($link, false); |
202 | $importCount++; | 176 | $importCount++; |
203 | } | 177 | } |
204 | 178 | ||
205 | $bookmarkService->save(); | 179 | $this->bookmarkService->save(); |
206 | $history->importLinks(); | 180 | $this->history->importLinks(); |
207 | 181 | ||
208 | $duration = time() - $start; | 182 | $duration = time() - $start; |
209 | return self::importStatus( | 183 | |
184 | return $this->importStatus( | ||
210 | $filename, | 185 | $filename, |
211 | $filesize, | 186 | $filesize, |
212 | $importCount, | 187 | $importCount, |
@@ -215,4 +190,39 @@ class NetscapeBookmarkUtils | |||
215 | $duration | 190 | $duration |
216 | ); | 191 | ); |
217 | } | 192 | } |
193 | |||
194 | /** | ||
195 | * Generates an import status summary | ||
196 | * | ||
197 | * @param string $filename name of the file to import | ||
198 | * @param int $filesize size of the file to import | ||
199 | * @param int $importCount how many bookmarks were imported | ||
200 | * @param int $overwriteCount how many bookmarks were overwritten | ||
201 | * @param int $skipCount how many bookmarks were skipped | ||
202 | * @param int $duration how many seconds did the import take | ||
203 | * | ||
204 | * @return string Summary of the bookmark import status | ||
205 | */ | ||
206 | protected function importStatus( | ||
207 | $filename, | ||
208 | $filesize, | ||
209 | $importCount = 0, | ||
210 | $overwriteCount = 0, | ||
211 | $skipCount = 0, | ||
212 | $duration = 0 | ||
213 | ) { | ||
214 | $status = sprintf(t('File %s (%d bytes) '), $filename, $filesize); | ||
215 | if ($importCount == 0 && $overwriteCount == 0 && $skipCount == 0) { | ||
216 | $status .= t('has an unknown file format. Nothing was imported.'); | ||
217 | } else { | ||
218 | $status .= vsprintf( | ||
219 | t( | ||
220 | 'was successfully processed in %d seconds: ' | ||
221 | . '%d bookmarks imported, %d bookmarks overwritten, %d bookmarks skipped.' | ||
222 | ), | ||
223 | [$duration, $importCount, $overwriteCount, $skipCount] | ||
224 | ); | ||
225 | } | ||
226 | return $status; | ||
227 | } | ||
218 | } | 228 | } |
@@ -662,13 +662,8 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
662 | if (! $sessionManager->checkToken($_POST['token'])) { | 662 | if (! $sessionManager->checkToken($_POST['token'])) { |
663 | die('Wrong token.'); | 663 | die('Wrong token.'); |
664 | } | 664 | } |
665 | $status = NetscapeBookmarkUtils::import( | 665 | $netscapeBookmarkUtils = new NetscapeBookmarkUtils($bookmarkService, $conf, $history); |
666 | $_POST, | 666 | $status = $netscapeBookmarkUtils->import($_POST, $_FILES); |
667 | $_FILES, | ||
668 | $bookmarkService, | ||
669 | $conf, | ||
670 | $history | ||
671 | ); | ||
672 | echo '<script>alert("'.$status.'");document.location=\'./?do=' | 667 | echo '<script>alert("'.$status.'");document.location=\'./?do=' |
673 | .Router::$PAGE_IMPORT .'\';</script>'; | 668 | .Router::$PAGE_IMPORT .'\';</script>'; |
674 | exit; | 669 | exit; |
diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php index 6c948bba..344c1dc0 100644 --- a/tests/netscape/BookmarkExportTest.php +++ b/tests/netscape/BookmarkExportTest.php | |||
@@ -1,11 +1,12 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
2 | namespace Shaarli\Netscape; | 3 | namespace Shaarli\Netscape; |
3 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | ||
4 | use Shaarli\Bookmark\BookmarkFileService; | 6 | use Shaarli\Bookmark\BookmarkFileService; |
5 | use Shaarli\Bookmark\LinkDB; | ||
6 | use Shaarli\Config\ConfigManager; | 7 | use Shaarli\Config\ConfigManager; |
7 | use Shaarli\Formatter\FormatterFactory; | ||
8 | use Shaarli\Formatter\BookmarkFormatter; | 8 | use Shaarli\Formatter\BookmarkFormatter; |
9 | use Shaarli\Formatter\FormatterFactory; | ||
9 | use Shaarli\History; | 10 | use Shaarli\History; |
10 | 11 | ||
11 | require_once 'tests/utils/ReferenceLinkDB.php'; | 12 | require_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 | */ |
16 | class BookmarkExportTest extends \PHPUnit\Framework\TestCase | 17 | class 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,8 +170,7 @@ 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, |
@@ -168,8 +188,7 @@ 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, |
diff --git a/tests/netscape/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php index fef7f6d1..20b1c6f4 100644 --- a/tests/netscape/BookmarkImportTest.php +++ b/tests/netscape/BookmarkImportTest.php | |||
@@ -1,11 +1,12 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
2 | namespace Shaarli\Netscape; | 3 | namespace Shaarli\Netscape; |
3 | 4 | ||
4 | use DateTime; | 5 | use DateTime; |
6 | use PHPUnit\Framework\TestCase; | ||
5 | use Shaarli\Bookmark\Bookmark; | 7 | use Shaarli\Bookmark\Bookmark; |
6 | use Shaarli\Bookmark\BookmarkFilter; | ||
7 | use Shaarli\Bookmark\BookmarkFileService; | 8 | use Shaarli\Bookmark\BookmarkFileService; |
8 | use Shaarli\Bookmark\LinkDB; | 9 | use Shaarli\Bookmark\BookmarkFilter; |
9 | use Shaarli\Config\ConfigManager; | 10 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\History; | 11 | use Shaarli\History; |
11 | 12 | ||
@@ -31,7 +32,7 @@ function file2array($filename) | |||
31 | /** | 32 | /** |
32 | * Netscape bookmark import | 33 | * Netscape bookmark import |
33 | */ | 34 | */ |
34 | class BookmarkImportTest extends \PHPUnit\Framework\TestCase | 35 | class BookmarkImportTest extends TestCase |
35 | { | 36 | { |
36 | /** | 37 | /** |
37 | * @var string datastore to test write operations | 38 | * @var string datastore to test write operations |
@@ -64,6 +65,11 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
64 | protected $history; | 65 | protected $history; |
65 | 66 | ||
66 | /** | 67 | /** |
68 | * @var NetscapeBookmarkUtils | ||
69 | */ | ||
70 | protected $netscapeBookmarkUtils; | ||
71 | |||
72 | /** | ||
67 | * @var string Save the current timezone. | 73 | * @var string Save the current timezone. |
68 | */ | 74 | */ |
69 | protected static $defaultTimeZone; | 75 | protected static $defaultTimeZone; |
@@ -91,6 +97,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
91 | $this->conf->set('resource.datastore', self::$testDatastore); | 97 | $this->conf->set('resource.datastore', self::$testDatastore); |
92 | $this->history = new History(self::$historyFilePath); | 98 | $this->history = new History(self::$historyFilePath); |
93 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); | 99 | $this->bookmarkService = new BookmarkFileService($this->conf, $this->history, true); |
100 | $this->netscapeBookmarkUtils = new NetscapeBookmarkUtils($this->bookmarkService, $this->conf, $this->history); | ||
94 | } | 101 | } |
95 | 102 | ||
96 | /** | 103 | /** |
@@ -115,7 +122,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
115 | $this->assertEquals( | 122 | $this->assertEquals( |
116 | 'File empty.htm (0 bytes) has an unknown file format.' | 123 | 'File empty.htm (0 bytes) has an unknown file format.' |
117 | .' Nothing was imported.', | 124 | .' Nothing was imported.', |
118 | NetscapeBookmarkUtils::import(null, $files, null, $this->conf, $this->history) | 125 | $this->netscapeBookmarkUtils->import(null, $files) |
119 | ); | 126 | ); |
120 | $this->assertEquals(0, $this->bookmarkService->count()); | 127 | $this->assertEquals(0, $this->bookmarkService->count()); |
121 | } | 128 | } |
@@ -128,7 +135,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
128 | $files = file2array('no_doctype.htm'); | 135 | $files = file2array('no_doctype.htm'); |
129 | $this->assertEquals( | 136 | $this->assertEquals( |
130 | 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', | 137 | 'File no_doctype.htm (350 bytes) has an unknown file format. Nothing was imported.', |
131 | NetscapeBookmarkUtils::import(null, $files, null, $this->conf, $this->history) | 138 | $this->netscapeBookmarkUtils->import(null, $files) |
132 | ); | 139 | ); |
133 | $this->assertEquals(0, $this->bookmarkService->count()); | 140 | $this->assertEquals(0, $this->bookmarkService->count()); |
134 | } | 141 | } |
@@ -142,7 +149,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
142 | $this->assertStringMatchesFormat( | 149 | $this->assertStringMatchesFormat( |
143 | 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:' | 150 | 'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:' |
144 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 151 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
145 | NetscapeBookmarkUtils::import(null, $files, $this->bookmarkService, $this->conf, $this->history) | 152 | $this->netscapeBookmarkUtils->import(null, $files) |
146 | ); | 153 | ); |
147 | $this->assertEquals(2, $this->bookmarkService->count()); | 154 | $this->assertEquals(2, $this->bookmarkService->count()); |
148 | } | 155 | } |
@@ -157,7 +164,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
157 | $this->assertStringMatchesFormat( | 164 | $this->assertStringMatchesFormat( |
158 | 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:' | 165 | 'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:' |
159 | .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 166 | .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
160 | NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) | 167 | $this->netscapeBookmarkUtils->import([], $files) |
161 | ); | 168 | ); |
162 | $this->assertEquals(1, $this->bookmarkService->count()); | 169 | $this->assertEquals(1, $this->bookmarkService->count()); |
163 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 170 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -185,7 +192,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
185 | $this->assertStringMatchesFormat( | 192 | $this->assertStringMatchesFormat( |
186 | 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:' | 193 | 'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:' |
187 | .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 194 | .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
188 | NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) | 195 | $this->netscapeBookmarkUtils->import([], $files) |
189 | ); | 196 | ); |
190 | $this->assertEquals(8, $this->bookmarkService->count()); | 197 | $this->assertEquals(8, $this->bookmarkService->count()); |
191 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 198 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -306,7 +313,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
306 | $this->assertStringMatchesFormat( | 313 | $this->assertStringMatchesFormat( |
307 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 314 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
308 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 315 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
309 | NetscapeBookmarkUtils::import([], $files, $this->bookmarkService, $this->conf, $this->history) | 316 | $this->netscapeBookmarkUtils->import([], $files) |
310 | ); | 317 | ); |
311 | 318 | ||
312 | $this->assertEquals(2, $this->bookmarkService->count()); | 319 | $this->assertEquals(2, $this->bookmarkService->count()); |
@@ -349,7 +356,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
349 | $this->assertStringMatchesFormat( | 356 | $this->assertStringMatchesFormat( |
350 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 357 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
351 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 358 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
352 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 359 | $this->netscapeBookmarkUtils->import($post, $files) |
353 | ); | 360 | ); |
354 | 361 | ||
355 | $this->assertEquals(2, $this->bookmarkService->count()); | 362 | $this->assertEquals(2, $this->bookmarkService->count()); |
@@ -392,7 +399,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
392 | $this->assertStringMatchesFormat( | 399 | $this->assertStringMatchesFormat( |
393 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 400 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
394 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 401 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
395 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 402 | $this->netscapeBookmarkUtils->import($post, $files) |
396 | ); | 403 | ); |
397 | $this->assertEquals(2, $this->bookmarkService->count()); | 404 | $this->assertEquals(2, $this->bookmarkService->count()); |
398 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 405 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -410,7 +417,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
410 | $this->assertStringMatchesFormat( | 417 | $this->assertStringMatchesFormat( |
411 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 418 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
412 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 419 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
413 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 420 | $this->netscapeBookmarkUtils->import($post, $files) |
414 | ); | 421 | ); |
415 | $this->assertEquals(2, $this->bookmarkService->count()); | 422 | $this->assertEquals(2, $this->bookmarkService->count()); |
416 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 423 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -430,7 +437,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
430 | $this->assertStringMatchesFormat( | 437 | $this->assertStringMatchesFormat( |
431 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 438 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
432 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 439 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
433 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 440 | $this->netscapeBookmarkUtils->import($post, $files) |
434 | ); | 441 | ); |
435 | $this->assertEquals(2, $this->bookmarkService->count()); | 442 | $this->assertEquals(2, $this->bookmarkService->count()); |
436 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 443 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -445,7 +452,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
445 | $this->assertStringMatchesFormat( | 452 | $this->assertStringMatchesFormat( |
446 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 453 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
447 | .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', | 454 | .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', |
448 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 455 | $this->netscapeBookmarkUtils->import($post, $files) |
449 | ); | 456 | ); |
450 | $this->assertEquals(2, $this->bookmarkService->count()); | 457 | $this->assertEquals(2, $this->bookmarkService->count()); |
451 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 458 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -465,7 +472,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
465 | $this->assertStringMatchesFormat( | 472 | $this->assertStringMatchesFormat( |
466 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 473 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
467 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 474 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
468 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 475 | $this->netscapeBookmarkUtils->import($post, $files) |
469 | ); | 476 | ); |
470 | $this->assertEquals(2, $this->bookmarkService->count()); | 477 | $this->assertEquals(2, $this->bookmarkService->count()); |
471 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 478 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -480,7 +487,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
480 | $this->assertStringMatchesFormat( | 487 | $this->assertStringMatchesFormat( |
481 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 488 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
482 | .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', | 489 | .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.', |
483 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 490 | $this->netscapeBookmarkUtils->import($post, $files) |
484 | ); | 491 | ); |
485 | $this->assertEquals(2, $this->bookmarkService->count()); | 492 | $this->assertEquals(2, $this->bookmarkService->count()); |
486 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 493 | $this->assertEquals(2, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -498,7 +505,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
498 | $this->assertStringMatchesFormat( | 505 | $this->assertStringMatchesFormat( |
499 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 506 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
500 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 507 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
501 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 508 | $this->netscapeBookmarkUtils->import($post, $files) |
502 | ); | 509 | ); |
503 | $this->assertEquals(2, $this->bookmarkService->count()); | 510 | $this->assertEquals(2, $this->bookmarkService->count()); |
504 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 511 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -508,7 +515,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
508 | $this->assertStringMatchesFormat( | 515 | $this->assertStringMatchesFormat( |
509 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 516 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
510 | .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.', | 517 | .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.', |
511 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 518 | $this->netscapeBookmarkUtils->import($post, $files) |
512 | ); | 519 | ); |
513 | $this->assertEquals(2, $this->bookmarkService->count()); | 520 | $this->assertEquals(2, $this->bookmarkService->count()); |
514 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 521 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -527,7 +534,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
527 | $this->assertStringMatchesFormat( | 534 | $this->assertStringMatchesFormat( |
528 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 535 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
529 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 536 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
530 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 537 | $this->netscapeBookmarkUtils->import($post, $files) |
531 | ); | 538 | ); |
532 | $this->assertEquals(2, $this->bookmarkService->count()); | 539 | $this->assertEquals(2, $this->bookmarkService->count()); |
533 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 540 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -548,7 +555,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
548 | $this->assertStringMatchesFormat( | 555 | $this->assertStringMatchesFormat( |
549 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' | 556 | 'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:' |
550 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 557 | .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
551 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history) | 558 | $this->netscapeBookmarkUtils->import($post, $files) |
552 | ); | 559 | ); |
553 | $this->assertEquals(2, $this->bookmarkService->count()); | 560 | $this->assertEquals(2, $this->bookmarkService->count()); |
554 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 561 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -573,7 +580,7 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
573 | $this->assertStringMatchesFormat( | 580 | $this->assertStringMatchesFormat( |
574 | 'File same_date.htm (453 bytes) was successfully processed in %d seconds:' | 581 | 'File same_date.htm (453 bytes) was successfully processed in %d seconds:' |
575 | .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', | 582 | .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.', |
576 | NetscapeBookmarkUtils::import(array(), $files, $this->bookmarkService, $this->conf, $this->history) | 583 | $this->netscapeBookmarkUtils->import(array(), $files) |
577 | ); | 584 | ); |
578 | $this->assertEquals(3, $this->bookmarkService->count()); | 585 | $this->assertEquals(3, $this->bookmarkService->count()); |
579 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); | 586 | $this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE)); |
@@ -589,14 +596,14 @@ class BookmarkImportTest extends \PHPUnit\Framework\TestCase | |||
589 | 'overwrite' => 'true', | 596 | 'overwrite' => 'true', |
590 | ]; | 597 | ]; |
591 | $files = file2array('netscape_basic.htm'); | 598 | $files = file2array('netscape_basic.htm'); |
592 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history); | 599 | $this->netscapeBookmarkUtils->import($post, $files); |
593 | $history = $this->history->getHistory(); | 600 | $history = $this->history->getHistory(); |
594 | $this->assertEquals(1, count($history)); | 601 | $this->assertEquals(1, count($history)); |
595 | $this->assertEquals(History::IMPORT, $history[0]['event']); | 602 | $this->assertEquals(History::IMPORT, $history[0]['event']); |
596 | $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']); | 603 | $this->assertTrue(new DateTime('-5 seconds') < $history[0]['datetime']); |
597 | 604 | ||
598 | // re-import as private, enable overwriting | 605 | // re-import as private, enable overwriting |
599 | NetscapeBookmarkUtils::import($post, $files, $this->bookmarkService, $this->conf, $this->history); | 606 | $this->netscapeBookmarkUtils->import($post, $files); |
600 | $history = $this->history->getHistory(); | 607 | $history = $this->history->getHistory(); |
601 | $this->assertEquals(2, count($history)); | 608 | $this->assertEquals(2, count($history)); |
602 | $this->assertEquals(History::IMPORT, $history[0]['event']); | 609 | $this->assertEquals(History::IMPORT, $history[0]['event']); |