aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/LinkFilter.php2
-rw-r--r--application/LinkUtils.php2
-rw-r--r--application/NetscapeBookmarkUtils.php1
-rw-r--r--application/Updater.php2
-rw-r--r--application/api/ApiMiddleware.php2
-rw-r--r--application/api/controllers/ApiController.php2
-rw-r--r--application/bookmark/LinkDB.php (renamed from application/LinkDB.php)66
-rw-r--r--application/feed/CachedPage.php1
-rw-r--r--application/feed/FeedBuilder.php15
-rw-r--r--application/render/PageBuilder.php2
-rw-r--r--composer.json1
-rw-r--r--index.php3
-rw-r--r--tests/LinkFilterTest.php2
-rw-r--r--tests/NetscapeBookmarkUtils/BookmarkExportTest.php2
-rw-r--r--tests/NetscapeBookmarkUtils/BookmarkImportTest.php1
-rw-r--r--tests/Updater/DummyUpdater.php2
-rw-r--r--tests/Updater/UpdaterTest.php2
-rw-r--r--tests/api/controllers/info/InfoTest.php2
-rw-r--r--tests/api/controllers/links/DeleteLinkTest.php6
-rw-r--r--tests/api/controllers/links/GetLinkIdTest.php4
-rw-r--r--tests/api/controllers/links/GetLinksTest.php6
-rw-r--r--tests/api/controllers/links/PostLinkTest.php6
-rw-r--r--tests/api/controllers/links/PutLinkTest.php6
-rw-r--r--tests/api/controllers/tags/DeleteTagTest.php8
-rw-r--r--tests/api/controllers/tags/GetTagNameTest.php2
-rw-r--r--tests/api/controllers/tags/GetTagsTest.php4
-rw-r--r--tests/api/controllers/tags/PutTagTest.php4
-rw-r--r--tests/bookmark/LinkDBTest.php (renamed from tests/LinkDBTest.php)26
-rw-r--r--tests/feed/FeedBuilderTest.php4
-rw-r--r--tests/http/UrlTest.php1
-rw-r--r--tests/plugins/PluginIssoTest.php2
-rw-r--r--tests/utils/ReferenceLinkDB.php3
32 files changed, 115 insertions, 77 deletions
diff --git a/application/LinkFilter.php b/application/LinkFilter.php
index 8f147974..91c79905 100644
--- a/application/LinkFilter.php
+++ b/application/LinkFilter.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB;
4
3/** 5/**
4 * Class LinkFilter. 6 * Class LinkFilter.
5 * 7 *
diff --git a/application/LinkUtils.php b/application/LinkUtils.php
index d56e019f..b5110edc 100644
--- a/application/LinkUtils.php
+++ b/application/LinkUtils.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB;
4
3/** 5/**
4 * Get cURL callback function for CURLOPT_WRITEFUNCTION 6 * Get cURL callback function for CURLOPT_WRITEFUNCTION
5 * 7 *
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php
index c0c007ea..e0022fe1 100644
--- a/application/NetscapeBookmarkUtils.php
+++ b/application/NetscapeBookmarkUtils.php
@@ -1,6 +1,7 @@
1<?php 1<?php
2 2
3use Psr\Log\LogLevel; 3use Psr\Log\LogLevel;
4use Shaarli\Bookmark\LinkDB;
4use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
5use Shaarli\History; 6use Shaarli\History;
6use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; 7use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;
diff --git a/application/Updater.php b/application/Updater.php
index c0d541b4..043ecf68 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -1,4 +1,6 @@
1<?php 1<?php
2
3use Shaarli\Bookmark\LinkDB;
2use Shaarli\Config\ConfigJson; 4use Shaarli\Config\ConfigJson;
3use Shaarli\Config\ConfigPhp; 5use Shaarli\Config\ConfigPhp;
4use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
diff --git a/application/api/ApiMiddleware.php b/application/api/ApiMiddleware.php
index 66eac133..a2101f29 100644
--- a/application/api/ApiMiddleware.php
+++ b/application/api/ApiMiddleware.php
@@ -127,7 +127,7 @@ class ApiMiddleware
127 */ 127 */
128 protected function setLinkDb($conf) 128 protected function setLinkDb($conf)
129 { 129 {
130 $linkDb = new \LinkDB( 130 $linkDb = new \Shaarli\Bookmark\LinkDB(
131 $conf->get('resource.datastore'), 131 $conf->get('resource.datastore'),
132 true, 132 true,
133 $conf->get('privacy.hide_public_links'), 133 $conf->get('privacy.hide_public_links'),
diff --git a/application/api/controllers/ApiController.php b/application/api/controllers/ApiController.php
index 47e0e178..cab97dc4 100644
--- a/application/api/controllers/ApiController.php
+++ b/application/api/controllers/ApiController.php
@@ -25,7 +25,7 @@ abstract class ApiController
25 protected $conf; 25 protected $conf;
26 26
27 /** 27 /**
28 * @var \LinkDB 28 * @var \Shaarli\Bookmark\LinkDB
29 */ 29 */
30 protected $linkDb; 30 protected $linkDb;
31 31
diff --git a/application/LinkDB.php b/application/bookmark/LinkDB.php
index a5b42727..3b77422a 100644
--- a/application/LinkDB.php
+++ b/application/bookmark/LinkDB.php
@@ -1,5 +1,13 @@
1<?php 1<?php
2 2
3namespace Shaarli\Bookmark;
4
5use ArrayAccess;
6use Countable;
7use DateTime;
8use Iterator;
9use LinkFilter;
10use LinkNotFoundException;
3use Shaarli\Exceptions\IOException; 11use Shaarli\Exceptions\IOException;
4use Shaarli\FileUtils; 12use Shaarli\FileUtils;
5 13
@@ -99,10 +107,10 @@ class LinkDB implements Iterator, Countable, ArrayAccess
99 * 107 *
100 * Checks if the datastore exists; else, attempts to create a dummy one. 108 * Checks if the datastore exists; else, attempts to create a dummy one.
101 * 109 *
102 * @param string $datastore datastore file path. 110 * @param string $datastore datastore file path.
103 * @param boolean $isLoggedIn is the user logged in? 111 * @param boolean $isLoggedIn is the user logged in?
104 * @param boolean $hidePublicLinks if true all links are private. 112 * @param boolean $hidePublicLinks if true all links are private.
105 * @param string $redirector link redirector set in user settings. 113 * @param string $redirector link redirector set in user settings.
106 * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true). 114 * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true).
107 */ 115 */
108 public function __construct( 116 public function __construct(
@@ -112,6 +120,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
112 $redirector = '', 120 $redirector = '',
113 $redirectorEncode = true 121 $redirectorEncode = true
114 ) { 122 ) {
123
115 $this->datastore = $datastore; 124 $this->datastore = $datastore;
116 $this->loggedIn = $isLoggedIn; 125 $this->loggedIn = $isLoggedIn;
117 $this->hidePublicLinks = $hidePublicLinks; 126 $this->hidePublicLinks = $hidePublicLinks;
@@ -141,7 +150,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
141 if (!isset($value['id']) || empty($value['url'])) { 150 if (!isset($value['id']) || empty($value['url'])) {
142 die(t('Internal Error: A link should always have an id and URL.')); 151 die(t('Internal Error: A link should always have an id and URL.'));
143 } 152 }
144 if (($offset !== null && ! is_int($offset)) || ! is_int($value['id'])) { 153 if (($offset !== null && !is_int($offset)) || !is_int($value['id'])) {
145 die(t('You must specify an integer as a key.')); 154 die(t('You must specify an integer as a key.'));
146 } 155 }
147 if ($offset !== null && $offset !== $value['id']) { 156 if ($offset !== null && $offset !== $value['id']) {
@@ -251,31 +260,31 @@ class LinkDB implements Iterator, Countable, ArrayAccess
251 $this->links = array(); 260 $this->links = array();
252 $link = array( 261 $link = array(
253 'id' => 1, 262 'id' => 1,
254 'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'), 263 'title' => t('The personal, minimalist, super-fast, database free, bookmarking service'),
255 'url'=>'https://shaarli.readthedocs.io', 264 'url' => 'https://shaarli.readthedocs.io',
256 'description'=>t( 265 'description' => t(
257 'Welcome to Shaarli! This is your first public bookmark. ' 266 'Welcome to Shaarli! This is your first public bookmark. '
258 .'To edit or delete me, you must first login. 267 . 'To edit or delete me, you must first login.
259 268
260To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page. 269To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
261 270
262You use the community supported version of the original Shaarli project, by Sebastien Sauvage.' 271You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
263 ), 272 ),
264 'private'=>0, 273 'private' => 0,
265 'created'=> new DateTime(), 274 'created' => new DateTime(),
266 'tags'=>'opensource software' 275 'tags' => 'opensource software'
267 ); 276 );
268 $link['shorturl'] = link_small_hash($link['created'], $link['id']); 277 $link['shorturl'] = link_small_hash($link['created'], $link['id']);
269 $this->links[1] = $link; 278 $this->links[1] = $link;
270 279
271 $link = array( 280 $link = array(
272 'id' => 0, 281 'id' => 0,
273 'title'=> t('My secret stuff... - Pastebin.com'), 282 'title' => t('My secret stuff... - Pastebin.com'),
274 'url'=>'http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=', 283 'url' => 'http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=',
275 'description'=> t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'), 284 'description' => t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'),
276 'private'=>1, 285 'private' => 1,
277 'created'=> new DateTime('1 minute ago'), 286 'created' => new DateTime('1 minute ago'),
278 'tags'=>'secretstuff', 287 'tags' => 'secretstuff',
279 ); 288 );
280 $link['shorturl'] = link_small_hash($link['created'], $link['id']); 289 $link['shorturl'] = link_small_hash($link['created'], $link['id']);
281 $this->links[0] = $link; 290 $this->links[0] = $link;
@@ -301,7 +310,7 @@ You use the community supported version of the original Shaarli project, by Seba
301 310
302 $toremove = array(); 311 $toremove = array();
303 foreach ($this->links as $key => &$link) { 312 foreach ($this->links as $key => &$link) {
304 if (! $this->loggedIn && $link['private'] != 0) { 313 if (!$this->loggedIn && $link['private'] != 0) {
305 // Transition for not upgraded databases. 314 // Transition for not upgraded databases.
306 unset($this->links[$key]); 315 unset($this->links[$key]);
307 continue; 316 continue;
@@ -311,7 +320,7 @@ You use the community supported version of the original Shaarli project, by Seba
311 sanitizeLink($link); 320 sanitizeLink($link);
312 321
313 // Remove private tags if the user is not logged in. 322 // Remove private tags if the user is not logged in.
314 if (! $this->loggedIn) { 323 if (!$this->loggedIn) {
315 $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']); 324 $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']);
316 } 325 }
317 326
@@ -328,10 +337,10 @@ You use the community supported version of the original Shaarli project, by Seba
328 } 337 }
329 338
330 // To be able to load links before running the update, and prepare the update 339 // To be able to load links before running the update, and prepare the update
331 if (! isset($link['created'])) { 340 if (!isset($link['created'])) {
332 $link['id'] = $link['linkdate']; 341 $link['id'] = $link['linkdate'];
333 $link['created'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['linkdate']); 342 $link['created'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['linkdate']);
334 if (! empty($link['updated'])) { 343 if (!empty($link['updated'])) {
335 $link['updated'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['updated']); 344 $link['updated'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['updated']);
336 } 345 }
337 $link['shorturl'] = smallHash($link['linkdate']); 346 $link['shorturl'] = smallHash($link['linkdate']);
@@ -417,12 +426,12 @@ You use the community supported version of the original Shaarli project, by Seba
417 /** 426 /**
418 * Filter links according to search parameters. 427 * Filter links according to search parameters.
419 * 428 *
420 * @param array $filterRequest Search request content. Supported keys: 429 * @param array $filterRequest Search request content. Supported keys:
421 * - searchtags: list of tags 430 * - searchtags: list of tags
422 * - searchterm: term search 431 * - searchterm: term search
423 * @param bool $casesensitive Optional: Perform case sensitive filter 432 * @param bool $casesensitive Optional: Perform case sensitive filter
424 * @param string $visibility return only all/private/public links 433 * @param string $visibility return only all/private/public links
425 * @param string $untaggedonly return only untagged links 434 * @param string $untaggedonly return only untagged links
426 * 435 *
427 * @return array filtered links, all links if no suitable filter was provided. 436 * @return array filtered links, all links if no suitable filter was provided.
428 */ 437 */
@@ -432,6 +441,7 @@ You use the community supported version of the original Shaarli project, by Seba
432 $visibility = 'all', 441 $visibility = 'all',
433 $untaggedonly = false 442 $untaggedonly = false
434 ) { 443 ) {
444
435 // Filter link database according to parameters. 445 // Filter link database according to parameters.
436 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : ''; 446 $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
437 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : ''; 447 $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
@@ -448,7 +458,7 @@ You use the community supported version of the original Shaarli project, by Seba
448 * Returns the list tags appearing in the links with the given tags 458 * Returns the list tags appearing in the links with the given tags
449 * 459 *
450 * @param array $filteringTags tags selecting the links to consider 460 * @param array $filteringTags tags selecting the links to consider
451 * @param string $visibility process only all/private/public links 461 * @param string $visibility process only all/private/public links
452 * 462 *
453 * @return array tag => linksCount 463 * @return array tag => linksCount
454 */ 464 */
@@ -490,7 +500,7 @@ You use the community supported version of the original Shaarli project, by Seba
490 * Rename or delete a tag across all links. 500 * Rename or delete a tag across all links.
491 * 501 *
492 * @param string $from Tag to rename 502 * @param string $from Tag to rename
493 * @param string $to New tag. If none is provided, the from tag will be deleted 503 * @param string $to New tag. If none is provided, the from tag will be deleted
494 * 504 *
495 * @return array|bool List of altered links or false on error 505 * @return array|bool List of altered links or false on error
496 */ 506 */
diff --git a/application/feed/CachedPage.php b/application/feed/CachedPage.php
index 1c51ac73..d809bdd9 100644
--- a/application/feed/CachedPage.php
+++ b/application/feed/CachedPage.php
@@ -1,6 +1,7 @@
1<?php 1<?php
2 2
3namespace Shaarli\Feed; 3namespace Shaarli\Feed;
4
4/** 5/**
5 * Simple cache system, mainly for the RSS/ATOM feeds 6 * Simple cache system, mainly for the RSS/ATOM feeds
6 */ 7 */
diff --git a/application/feed/FeedBuilder.php b/application/feed/FeedBuilder.php
index dcfd2c89..737a3128 100644
--- a/application/feed/FeedBuilder.php
+++ b/application/feed/FeedBuilder.php
@@ -2,7 +2,7 @@
2namespace Shaarli\Feed; 2namespace Shaarli\Feed;
3 3
4use DateTime; 4use DateTime;
5use LinkDB; 5use Shaarli\Bookmark\LinkDB;
6 6
7/** 7/**
8 * FeedBuilder class. 8 * FeedBuilder class.
@@ -32,7 +32,7 @@ class FeedBuilder
32 public static $DEFAULT_NB_LINKS = 50; 32 public static $DEFAULT_NB_LINKS = 50;
33 33
34 /** 34 /**
35 * @var LinkDB instance. 35 * @var \Shaarli\Bookmark\LinkDB instance.
36 */ 36 */
37 protected $linkDB; 37 protected $linkDB;
38 38
@@ -79,11 +79,12 @@ class FeedBuilder
79 /** 79 /**
80 * Feed constructor. 80 * Feed constructor.
81 * 81 *
82 * @param LinkDB $linkDB LinkDB instance. 82 * @param \Shaarli\Bookmark\LinkDB $linkDB LinkDB instance.
83 * @param string $feedType Type of feed. 83 * @param string $feedType Type of feed.
84 * @param array $serverInfo $_SERVER. 84 * @param array $serverInfo $_SERVER.
85 * @param array $userInput $_GET. 85 * @param array $userInput $_GET.
86 * @param boolean $isLoggedIn True if the user is currently logged in, false otherwise. 86 * @param boolean $isLoggedIn True if the user is currently logged in,
87 * false otherwise.
87 */ 88 */
88 public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn) 89 public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn)
89 { 90 {
diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php
index 1df95bfb..9a0fe61a 100644
--- a/application/render/PageBuilder.php
+++ b/application/render/PageBuilder.php
@@ -4,7 +4,7 @@ namespace Shaarli\Render;
4 4
5use ApplicationUtils; 5use ApplicationUtils;
6use Exception; 6use Exception;
7use LinkDB; 7use Shaarli\Bookmark\LinkDB;
8use RainTPL; 8use RainTPL;
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\Thumbnailer; 10use Shaarli\Thumbnailer;
diff --git a/composer.json b/composer.json
index 422a3a4e..e8dc2eb1 100644
--- a/composer.json
+++ b/composer.json
@@ -35,6 +35,7 @@
35 "Shaarli\\Api\\": "application/api/", 35 "Shaarli\\Api\\": "application/api/",
36 "Shaarli\\Api\\Controllers\\": "application/api/controllers", 36 "Shaarli\\Api\\Controllers\\": "application/api/controllers",
37 "Shaarli\\Api\\Exceptions\\": "application/api/exceptions", 37 "Shaarli\\Api\\Exceptions\\": "application/api/exceptions",
38 "Shaarli\\Bookmark\\": "application/bookmark",
38 "Shaarli\\Config\\": "application/config/", 39 "Shaarli\\Config\\": "application/config/",
39 "Shaarli\\Config\\Exception\\": "application/config/exception", 40 "Shaarli\\Config\\Exception\\": "application/config/exception",
40 "Shaarli\\Exceptions\\": "application/exceptions", 41 "Shaarli\\Exceptions\\": "application/exceptions",
diff --git a/index.php b/index.php
index 719b622c..b1d37a01 100644
--- a/index.php
+++ b/index.php
@@ -63,7 +63,6 @@ require_once 'application/http/HttpUtils.php';
63require_once 'application/http/UrlUtils.php'; 63require_once 'application/http/UrlUtils.php';
64require_once 'application/FileUtils.php'; 64require_once 'application/FileUtils.php';
65require_once 'application/History.php'; 65require_once 'application/History.php';
66require_once 'application/LinkDB.php';
67require_once 'application/LinkFilter.php'; 66require_once 'application/LinkFilter.php';
68require_once 'application/LinkUtils.php'; 67require_once 'application/LinkUtils.php';
69require_once 'application/NetscapeBookmarkUtils.php'; 68require_once 'application/NetscapeBookmarkUtils.php';
@@ -72,6 +71,8 @@ require_once 'application/Utils.php';
72require_once 'application/PluginManager.php'; 71require_once 'application/PluginManager.php';
73require_once 'application/Router.php'; 72require_once 'application/Router.php';
74require_once 'application/Updater.php'; 73require_once 'application/Updater.php';
74
75use \Shaarli\Bookmark\LinkDB;
75use \Shaarli\Config\ConfigManager; 76use \Shaarli\Config\ConfigManager;
76use \Shaarli\Feed\CachedPage; 77use \Shaarli\Feed\CachedPage;
77use \Shaarli\Feed\FeedBuilder; 78use \Shaarli\Feed\FeedBuilder;
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php
index eb54c359..db28b1c4 100644
--- a/tests/LinkFilterTest.php
+++ b/tests/LinkFilterTest.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB;
4
3require_once 'application/LinkFilter.php'; 5require_once 'application/LinkFilter.php';
4 6
5/** 7/**
diff --git a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php b/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
index 77fbd5f3..adf854c5 100644
--- a/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
+++ b/tests/NetscapeBookmarkUtils/BookmarkExportTest.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB;
4
3require_once 'application/NetscapeBookmarkUtils.php'; 5require_once 'application/NetscapeBookmarkUtils.php';
4 6
5/** 7/**
diff --git a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
index 07411c85..98c989bc 100644
--- a/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
+++ b/tests/NetscapeBookmarkUtils/BookmarkImportTest.php
@@ -2,6 +2,7 @@
2 2
3require_once 'application/NetscapeBookmarkUtils.php'; 3require_once 'application/NetscapeBookmarkUtils.php';
4 4
5use Shaarli\Bookmark\LinkDB;
5use Shaarli\Config\ConfigManager; 6use Shaarli\Config\ConfigManager;
6use Shaarli\History; 7use Shaarli\History;
7 8
diff --git a/tests/Updater/DummyUpdater.php b/tests/Updater/DummyUpdater.php
index a805ab5e..3c74b4ff 100644
--- a/tests/Updater/DummyUpdater.php
+++ b/tests/Updater/DummyUpdater.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Bookmark\LinkDB;
4
3require_once 'application/Updater.php'; 5require_once 'application/Updater.php';
4 6
5/** 7/**
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index c4a6e7ef..f910e054 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/Updater/UpdaterTest.php
@@ -1,4 +1,6 @@
1<?php 1<?php
2
3use Shaarli\Bookmark\LinkDB;
2use Shaarli\Config\ConfigJson; 4use Shaarli\Config\ConfigJson;
3use Shaarli\Config\ConfigManager; 5use Shaarli\Config\ConfigManager;
4use Shaarli\Config\ConfigPhp; 6use Shaarli\Config\ConfigPhp;
diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php
index e437082a..44a9382e 100644
--- a/tests/api/controllers/info/InfoTest.php
+++ b/tests/api/controllers/info/InfoTest.php
@@ -53,7 +53,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
53 53
54 $this->container = new Container(); 54 $this->container = new Container();
55 $this->container['conf'] = $this->conf; 55 $this->container['conf'] = $this->conf;
56 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 56 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
57 $this->container['history'] = null; 57 $this->container['history'] = null;
58 58
59 $this->controller = new Info($this->container); 59 $this->controller = new Info($this->container);
diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php
index 07371e7a..adca9a4e 100644
--- a/tests/api/controllers/links/DeleteLinkTest.php
+++ b/tests/api/controllers/links/DeleteLinkTest.php
@@ -32,7 +32,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
32 protected $refDB = null; 32 protected $refDB = null;
33 33
34 /** 34 /**
35 * @var \LinkDB instance. 35 * @var \Shaarli\Bookmark\LinkDB instance.
36 */ 36 */
37 protected $linkDB; 37 protected $linkDB;
38 38
@@ -59,7 +59,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
59 $this->conf = new ConfigManager('tests/utils/config/configJson'); 59 $this->conf = new ConfigManager('tests/utils/config/configJson');
60 $this->refDB = new \ReferenceLinkDB(); 60 $this->refDB = new \ReferenceLinkDB();
61 $this->refDB->write(self::$testDatastore); 61 $this->refDB->write(self::$testDatastore);
62 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 62 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
63 $refHistory = new \ReferenceHistory(); 63 $refHistory = new \ReferenceHistory();
64 $refHistory->write(self::$testHistory); 64 $refHistory->write(self::$testHistory);
65 $this->history = new \Shaarli\History(self::$testHistory); 65 $this->history = new \Shaarli\History(self::$testHistory);
@@ -96,7 +96,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
96 $this->assertEquals(204, $response->getStatusCode()); 96 $this->assertEquals(204, $response->getStatusCode());
97 $this->assertEmpty((string) $response->getBody()); 97 $this->assertEmpty((string) $response->getBody());
98 98
99 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 99 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
100 $this->assertFalse(isset($this->linkDB[$id])); 100 $this->assertFalse(isset($this->linkDB[$id]));
101 101
102 $historyEntry = $this->history->getHistory()[0]; 102 $historyEntry = $this->history->getHistory()[0];
diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php
index 57528d5a..bf58000b 100644
--- a/tests/api/controllers/links/GetLinkIdTest.php
+++ b/tests/api/controllers/links/GetLinkIdTest.php
@@ -61,7 +61,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
61 61
62 $this->container = new Container(); 62 $this->container = new Container();
63 $this->container['conf'] = $this->conf; 63 $this->container['conf'] = $this->conf;
64 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 64 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
65 $this->container['history'] = null; 65 $this->container['history'] = null;
66 66
67 $this->controller = new Links($this->container); 67 $this->controller = new Links($this->container);
@@ -108,7 +108,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
108 $this->assertEquals('sTuff', $data['tags'][0]); 108 $this->assertEquals('sTuff', $data['tags'][0]);
109 $this->assertEquals(false, $data['private']); 109 $this->assertEquals(false, $data['private']);
110 $this->assertEquals( 110 $this->assertEquals(
111 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), 111 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
112 $data['created'] 112 $data['created']
113 ); 113 );
114 $this->assertEmpty($data['updated']); 114 $this->assertEmpty($data['updated']);
diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php
index 64f02774..1008d7b2 100644
--- a/tests/api/controllers/links/GetLinksTest.php
+++ b/tests/api/controllers/links/GetLinksTest.php
@@ -60,7 +60,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
60 60
61 $this->container = new Container(); 61 $this->container = new Container();
62 $this->container['conf'] = $this->conf; 62 $this->container['conf'] = $this->conf;
63 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 63 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
64 $this->container['history'] = null; 64 $this->container['history'] = null;
65 65
66 $this->controller = new Links($this->container); 66 $this->controller = new Links($this->container);
@@ -114,7 +114,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
114 $this->assertEquals('sTuff', $first['tags'][0]); 114 $this->assertEquals('sTuff', $first['tags'][0]);
115 $this->assertEquals(false, $first['private']); 115 $this->assertEquals(false, $first['private']);
116 $this->assertEquals( 116 $this->assertEquals(
117 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), 117 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
118 $first['created'] 118 $first['created']
119 ); 119 );
120 $this->assertEmpty($first['updated']); 120 $this->assertEmpty($first['updated']);
@@ -125,7 +125,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
125 125
126 // Update date 126 // Update date
127 $this->assertEquals( 127 $this->assertEquals(
128 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), 128 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM),
129 $link['updated'] 129 $link['updated']
130 ); 130 );
131 } 131 }
diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php
index a73f443c..ade07eeb 100644
--- a/tests/api/controllers/links/PostLinkTest.php
+++ b/tests/api/controllers/links/PostLinkTest.php
@@ -74,7 +74,7 @@ class PostLinkTest extends TestCase
74 74
75 $this->container = new Container(); 75 $this->container = new Container();
76 $this->container['conf'] = $this->conf; 76 $this->container['conf'] = $this->conf;
77 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 77 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
78 $this->container['history'] = new \Shaarli\History(self::$testHistory); 78 $this->container['history'] = new \Shaarli\History(self::$testHistory);
79 79
80 $this->controller = new Links($this->container); 80 $this->controller = new Links($this->container);
@@ -210,11 +210,11 @@ class PostLinkTest extends TestCase
210 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']); 210 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
211 $this->assertEquals(false, $data['private']); 211 $this->assertEquals(false, $data['private']);
212 $this->assertEquals( 212 $this->assertEquals(
213 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'), 213 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
214 \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) 214 \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
215 ); 215 );
216 $this->assertEquals( 216 $this->assertEquals(
217 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'), 217 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
218 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) 218 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
219 ); 219 );
220 } 220 }
diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php
index 3bb4d43f..eb6c7955 100644
--- a/tests/api/controllers/links/PutLinkTest.php
+++ b/tests/api/controllers/links/PutLinkTest.php
@@ -66,7 +66,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
66 66
67 $this->container = new Container(); 67 $this->container = new Container();
68 $this->container['conf'] = $this->conf; 68 $this->container['conf'] = $this->conf;
69 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 69 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
70 $this->container['history'] = new \Shaarli\History(self::$testHistory); 70 $this->container['history'] = new \Shaarli\History(self::$testHistory);
71 71
72 $this->controller = new Links($this->container); 72 $this->controller = new Links($this->container);
@@ -198,11 +198,11 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
198 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']); 198 $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
199 $this->assertEquals(false, $data['private']); 199 $this->assertEquals(false, $data['private']);
200 $this->assertEquals( 200 $this->assertEquals(
201 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'), 201 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
202 \DateTime::createFromFormat(\DateTime::ATOM, $data['created']) 202 \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
203 ); 203 );
204 $this->assertEquals( 204 $this->assertEquals(
205 \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'), 205 \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
206 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']) 206 \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
207 ); 207 );
208 } 208 }
diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php
index a1e419cd..02803ba2 100644
--- a/tests/api/controllers/tags/DeleteTagTest.php
+++ b/tests/api/controllers/tags/DeleteTagTest.php
@@ -32,7 +32,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
32 protected $refDB = null; 32 protected $refDB = null;
33 33
34 /** 34 /**
35 * @var \LinkDB instance. 35 * @var \Shaarli\Bookmark\LinkDB instance.
36 */ 36 */
37 protected $linkDB; 37 protected $linkDB;
38 38
@@ -59,7 +59,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
59 $this->conf = new ConfigManager('tests/utils/config/configJson'); 59 $this->conf = new ConfigManager('tests/utils/config/configJson');
60 $this->refDB = new \ReferenceLinkDB(); 60 $this->refDB = new \ReferenceLinkDB();
61 $this->refDB->write(self::$testDatastore); 61 $this->refDB->write(self::$testDatastore);
62 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 62 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
63 $refHistory = new \ReferenceHistory(); 63 $refHistory = new \ReferenceHistory();
64 $refHistory->write(self::$testHistory); 64 $refHistory->write(self::$testHistory);
65 $this->history = new \Shaarli\History(self::$testHistory); 65 $this->history = new \Shaarli\History(self::$testHistory);
@@ -97,7 +97,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
97 $this->assertEquals(204, $response->getStatusCode()); 97 $this->assertEquals(204, $response->getStatusCode());
98 $this->assertEmpty((string) $response->getBody()); 98 $this->assertEmpty((string) $response->getBody());
99 99
100 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 100 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
101 $tags = $this->linkDB->linksCountPerTag(); 101 $tags = $this->linkDB->linksCountPerTag();
102 $this->assertFalse(isset($tags[$tagName])); 102 $this->assertFalse(isset($tags[$tagName]));
103 103
@@ -131,7 +131,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
131 $this->assertEquals(204, $response->getStatusCode()); 131 $this->assertEquals(204, $response->getStatusCode());
132 $this->assertEmpty((string) $response->getBody()); 132 $this->assertEmpty((string) $response->getBody());
133 133
134 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 134 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
135 $tags = $this->linkDB->linksCountPerTag(); 135 $tags = $this->linkDB->linksCountPerTag();
136 $this->assertFalse(isset($tags[$tagName])); 136 $this->assertFalse(isset($tags[$tagName]));
137 $this->assertTrue($tags[strtolower($tagName)] > 0); 137 $this->assertTrue($tags[strtolower($tagName)] > 0);
diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php
index afac228e..8e0feccd 100644
--- a/tests/api/controllers/tags/GetTagNameTest.php
+++ b/tests/api/controllers/tags/GetTagNameTest.php
@@ -59,7 +59,7 @@ class GetTagNameTest extends \PHPUnit_Framework_TestCase
59 59
60 $this->container = new Container(); 60 $this->container = new Container();
61 $this->container['conf'] = $this->conf; 61 $this->container['conf'] = $this->conf;
62 $this->container['db'] = new \LinkDB(self::$testDatastore, true, false); 62 $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
63 $this->container['history'] = null; 63 $this->container['history'] = null;
64 64
65 $this->controller = new Tags($this->container); 65 $this->controller = new Tags($this->container);
diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php
index 3fab31b0..f071bfa8 100644
--- a/tests/api/controllers/tags/GetTagsTest.php
+++ b/tests/api/controllers/tags/GetTagsTest.php
@@ -38,7 +38,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase
38 protected $container; 38 protected $container;
39 39
40 /** 40 /**
41 * @var \LinkDB instance. 41 * @var \Shaarli\Bookmark\LinkDB instance.
42 */ 42 */
43 protected $linkDB; 43 protected $linkDB;
44 44
@@ -63,7 +63,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase
63 63
64 $this->container = new Container(); 64 $this->container = new Container();
65 $this->container['conf'] = $this->conf; 65 $this->container['conf'] = $this->conf;
66 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 66 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
67 $this->container['db'] = $this->linkDB; 67 $this->container['db'] = $this->linkDB;
68 $this->container['history'] = null; 68 $this->container['history'] = null;
69 69
diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php
index c45fa722..d8c0fec8 100644
--- a/tests/api/controllers/tags/PutTagTest.php
+++ b/tests/api/controllers/tags/PutTagTest.php
@@ -43,7 +43,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
43 protected $container; 43 protected $container;
44 44
45 /** 45 /**
46 * @var \LinkDB instance. 46 * @var \Shaarli\Bookmark\LinkDB instance.
47 */ 47 */
48 protected $linkDB; 48 protected $linkDB;
49 49
@@ -72,7 +72,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
72 72
73 $this->container = new Container(); 73 $this->container = new Container();
74 $this->container['conf'] = $this->conf; 74 $this->container['conf'] = $this->conf;
75 $this->linkDB = new \LinkDB(self::$testDatastore, true, false); 75 $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
76 $this->container['db'] = $this->linkDB; 76 $this->container['db'] = $this->linkDB;
77 $this->container['history'] = $this->history; 77 $this->container['history'] = $this->history;
78 78
diff --git a/tests/LinkDBTest.php b/tests/bookmark/LinkDBTest.php
index 737a2247..f18a3155 100644
--- a/tests/LinkDBTest.php
+++ b/tests/bookmark/LinkDBTest.php
@@ -3,9 +3,15 @@
3 * Link datastore tests 3 * Link datastore tests
4 */ 4 */
5 5
6namespace Shaarli\Bookmark;
7
8use DateTime;
9use LinkNotFoundException;
10use ReferenceLinkDB;
11use ReflectionClass;
12use Shaarli;
13
6require_once 'application/feed/Cache.php'; 14require_once 'application/feed/Cache.php';
7require_once 'application/FileUtils.php';
8require_once 'application/LinkDB.php';
9require_once 'application/Utils.php'; 15require_once 'application/Utils.php';
10require_once 'tests/utils/ReferenceLinkDB.php'; 16require_once 'tests/utils/ReferenceLinkDB.php';
11 17
@@ -13,7 +19,7 @@ require_once 'tests/utils/ReferenceLinkDB.php';
13/** 19/**
14 * Unitary tests for LinkDB 20 * Unitary tests for LinkDB
15 */ 21 */
16class LinkDBTest extends PHPUnit_Framework_TestCase 22class LinkDBTest extends \PHPUnit\Framework\TestCase
17{ 23{
18 // datastore to test write operations 24 // datastore to test write operations
19 protected static $testDatastore = 'sandbox/datastore.php'; 25 protected static $testDatastore = 'sandbox/datastore.php';
@@ -73,7 +79,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
73 */ 79 */
74 protected static function getMethod($name) 80 protected static function getMethod($name)
75 { 81 {
76 $class = new ReflectionClass('LinkDB'); 82 $class = new ReflectionClass('Shaarli\Bookmark\LinkDB');
77 $method = $class->getMethod($name); 83 $method = $class->getMethod($name);
78 $method->setAccessible(true); 84 $method->setAccessible(true);
79 return $method; 85 return $method;
@@ -187,12 +193,12 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
187 193
188 $link = array( 194 $link = array(
189 'id' => 42, 195 'id' => 42,
190 'title'=>'an additional link', 196 'title' => 'an additional link',
191 'url'=>'http://dum.my', 197 'url' => 'http://dum.my',
192 'description'=>'One more', 198 'description' => 'One more',
193 'private'=>0, 199 'private' => 0,
194 'created'=> DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'), 200 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'),
195 'tags'=>'unit test' 201 'tags' => 'unit test'
196 ); 202 );
197 $testDB[$link['id']] = $link; 203 $testDB[$link['id']] = $link;
198 $testDB->save('tests'); 204 $testDB->save('tests');
diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php
index 1fdbc60e..88d1c3ed 100644
--- a/tests/feed/FeedBuilderTest.php
+++ b/tests/feed/FeedBuilderTest.php
@@ -3,11 +3,9 @@
3namespace Shaarli\Feed; 3namespace Shaarli\Feed;
4 4
5use DateTime; 5use DateTime;
6use LinkDB; 6use Shaarli\Bookmark\LinkDB;
7use ReferenceLinkDB; 7use ReferenceLinkDB;
8 8
9require_once 'application/LinkDB.php';
10
11/** 9/**
12 * FeedBuilderTest class. 10 * FeedBuilderTest class.
13 * 11 *
diff --git a/tests/http/UrlTest.php b/tests/http/UrlTest.php
index 342b78a4..ae92f73a 100644
--- a/tests/http/UrlTest.php
+++ b/tests/http/UrlTest.php
@@ -5,7 +5,6 @@
5 5
6namespace Shaarli\Http; 6namespace Shaarli\Http;
7 7
8
9/** 8/**
10 * Unitary tests for URL utilities 9 * Unitary tests for URL utilities
11 */ 10 */
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index 2c9efbcd..f5fa1daa 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -1,4 +1,6 @@
1<?php 1<?php
2
3use Shaarli\Bookmark\LinkDB;
2use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
3 5
4require_once 'plugins/isso/isso.php'; 6require_once 'plugins/isso/isso.php';
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index 59679e38..c12bcb67 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -1,4 +1,7 @@
1<?php 1<?php
2
3use Shaarli\Bookmark\LinkDB;
4
2/** 5/**
3 * Populates a reference datastore to test LinkDB 6 * Populates a reference datastore to test LinkDB
4 */ 7 */