]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
namespacing: \Shaarli\Bookmark\LinkDB
authorVirtualTam <virtualtam@flibidi.net>
Mon, 3 Dec 2018 00:10:39 +0000 (01:10 +0100)
committerVirtualTam <virtualtam@flibidi.net>
Sat, 12 Jan 2019 21:47:48 +0000 (22:47 +0100)
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
32 files changed:
application/LinkFilter.php
application/LinkUtils.php
application/NetscapeBookmarkUtils.php
application/Updater.php
application/api/ApiMiddleware.php
application/api/controllers/ApiController.php
application/bookmark/LinkDB.php [moved from application/LinkDB.php with 90% similarity]
application/feed/CachedPage.php
application/feed/FeedBuilder.php
application/render/PageBuilder.php
composer.json
index.php
tests/LinkFilterTest.php
tests/NetscapeBookmarkUtils/BookmarkExportTest.php
tests/NetscapeBookmarkUtils/BookmarkImportTest.php
tests/Updater/DummyUpdater.php
tests/Updater/UpdaterTest.php
tests/api/controllers/info/InfoTest.php
tests/api/controllers/links/DeleteLinkTest.php
tests/api/controllers/links/GetLinkIdTest.php
tests/api/controllers/links/GetLinksTest.php
tests/api/controllers/links/PostLinkTest.php
tests/api/controllers/links/PutLinkTest.php
tests/api/controllers/tags/DeleteTagTest.php
tests/api/controllers/tags/GetTagNameTest.php
tests/api/controllers/tags/GetTagsTest.php
tests/api/controllers/tags/PutTagTest.php
tests/bookmark/LinkDBTest.php [moved from tests/LinkDBTest.php with 97% similarity]
tests/feed/FeedBuilderTest.php
tests/http/UrlTest.php
tests/plugins/PluginIssoTest.php
tests/utils/ReferenceLinkDB.php

index 8f147974e9d5cf232f3cf3f509b3401fcf5e6b84..91c79905280851473878059a7e6d8e57dd9b3265 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Shaarli\Bookmark\LinkDB;
+
 /**
  * Class LinkFilter.
  *
index d56e019f4246f40d94f7a2eb5b8f715d10c7f1a1..b5110edc490b645fdd124f760fa50e91caf7496d 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Shaarli\Bookmark\LinkDB;
+
 /**
  * Get cURL callback function for CURLOPT_WRITEFUNCTION
  *
index c0c007ea4a120ac3b11f5e883e512e7e334e504f..e0022fe1a391e333b0d58fcce8e4300fe66f2fa6 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use Psr\Log\LogLevel;
+use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigManager;
 use Shaarli\History;
 use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;
index c0d541b440eac363dae43a8682d82fe971600e0c..043ecf682d5a5dadd3cdf0566bb2e7cb59e297c7 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+
+use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigJson;
 use Shaarli\Config\ConfigPhp;
 use Shaarli\Config\ConfigManager;
index 66eac133649cf8c020c64164f7864b43ddf33a40..a2101f29fca7f1d0a6c0823c8bd6a133f6997643 100644 (file)
@@ -127,7 +127,7 @@ class ApiMiddleware
      */
     protected function setLinkDb($conf)
     {
-        $linkDb = new \LinkDB(
+        $linkDb = new \Shaarli\Bookmark\LinkDB(
             $conf->get('resource.datastore'),
             true,
             $conf->get('privacy.hide_public_links'),
index 47e0e1780919e6fc2b943d708ea0ef5672c0dc72..cab97dc42c5bb32bb3f72d9edb8eacb182d9ab0b 100644 (file)
@@ -25,7 +25,7 @@ abstract class ApiController
     protected $conf;
 
     /**
-     * @var \LinkDB
+     * @var \Shaarli\Bookmark\LinkDB
      */
     protected $linkDb;
 
similarity index 90%
rename from application/LinkDB.php
rename to application/bookmark/LinkDB.php
index a5b42727e8fbb8d9f0076d23708d7595fc8f574a..3b77422a25672dce722935df120115d2309db935 100644 (file)
@@ -1,5 +1,13 @@
 <?php
 
+namespace Shaarli\Bookmark;
+
+use ArrayAccess;
+use Countable;
+use DateTime;
+use Iterator;
+use LinkFilter;
+use LinkNotFoundException;
 use Shaarli\Exceptions\IOException;
 use Shaarli\FileUtils;
 
@@ -99,10 +107,10 @@ class LinkDB implements Iterator, Countable, ArrayAccess
      *
      * Checks if the datastore exists; else, attempts to create a dummy one.
      *
-     * @param string  $datastore        datastore file path.
-     * @param boolean $isLoggedIn       is the user logged in?
-     * @param boolean $hidePublicLinks  if true all links are private.
-     * @param string  $redirector       link redirector set in user settings.
+     * @param string $datastore datastore file path.
+     * @param boolean $isLoggedIn is the user logged in?
+     * @param boolean $hidePublicLinks if true all links are private.
+     * @param string $redirector link redirector set in user settings.
      * @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true).
      */
     public function __construct(
@@ -112,6 +120,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
         $redirector = '',
         $redirectorEncode = true
     ) {
+    
         $this->datastore = $datastore;
         $this->loggedIn = $isLoggedIn;
         $this->hidePublicLinks = $hidePublicLinks;
@@ -141,7 +150,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess
         if (!isset($value['id']) || empty($value['url'])) {
             die(t('Internal Error: A link should always have an id and URL.'));
         }
-        if (($offset !== null && ! is_int($offset)) || ! is_int($value['id'])) {
+        if (($offset !== null && !is_int($offset)) || !is_int($value['id'])) {
             die(t('You must specify an integer as a key.'));
         }
         if ($offset !== null && $offset !== $value['id']) {
@@ -251,31 +260,31 @@ class LinkDB implements Iterator, Countable, ArrayAccess
         $this->links = array();
         $link = array(
             'id' => 1,
-            'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'),
-            'url'=>'https://shaarli.readthedocs.io',
-            'description'=>t(
+            'title' => t('The personal, minimalist, super-fast, database free, bookmarking service'),
+            'url' => 'https://shaarli.readthedocs.io',
+            'description' => t(
                 'Welcome to Shaarli! This is your first public bookmark. '
-                .'To edit or delete me, you must first login.
+                . 'To edit or delete me, you must first login.
 
 To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
 
 You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
             ),
-            'private'=>0,
-            'created'=> new DateTime(),
-            'tags'=>'opensource software'
+            'private' => 0,
+            'created' => new DateTime(),
+            'tags' => 'opensource software'
         );
         $link['shorturl'] = link_small_hash($link['created'], $link['id']);
         $this->links[1] = $link;
 
         $link = array(
             'id' => 0,
-            'title'=> t('My secret stuff... - Pastebin.com'),
-            'url'=>'http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=',
-            'description'=> t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'),
-            'private'=>1,
-            'created'=> new DateTime('1 minute ago'),
-            'tags'=>'secretstuff',
+            'title' => t('My secret stuff... - Pastebin.com'),
+            'url' => 'http://sebsauvage.net/paste/?8434b27936c09649#bR7XsXhoTiLcqCpQbmOpBi3rq2zzQUC5hBI7ZT1O3x8=',
+            'description' => t('Shhhh! I\'m a private link only YOU can see. You can delete me too.'),
+            'private' => 1,
+            'created' => new DateTime('1 minute ago'),
+            'tags' => 'secretstuff',
         );
         $link['shorturl'] = link_small_hash($link['created'], $link['id']);
         $this->links[0] = $link;
@@ -301,7 +310,7 @@ You use the community supported version of the original Shaarli project, by Seba
 
         $toremove = array();
         foreach ($this->links as $key => &$link) {
-            if (! $this->loggedIn && $link['private'] != 0) {
+            if (!$this->loggedIn && $link['private'] != 0) {
                 // Transition for not upgraded databases.
                 unset($this->links[$key]);
                 continue;
@@ -311,7 +320,7 @@ You use the community supported version of the original Shaarli project, by Seba
             sanitizeLink($link);
 
             // Remove private tags if the user is not logged in.
-            if (! $this->loggedIn) {
+            if (!$this->loggedIn) {
                 $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']);
             }
 
@@ -328,10 +337,10 @@ You use the community supported version of the original Shaarli project, by Seba
             }
 
             // To be able to load links before running the update, and prepare the update
-            if (! isset($link['created'])) {
+            if (!isset($link['created'])) {
                 $link['id'] = $link['linkdate'];
                 $link['created'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['linkdate']);
-                if (! empty($link['updated'])) {
+                if (!empty($link['updated'])) {
                     $link['updated'] = DateTime::createFromFormat(self::LINK_DATE_FORMAT, $link['updated']);
                 }
                 $link['shorturl'] = smallHash($link['linkdate']);
@@ -417,12 +426,12 @@ You use the community supported version of the original Shaarli project, by Seba
     /**
      * Filter links according to search parameters.
      *
-     * @param array  $filterRequest Search request content. Supported keys:
+     * @param array $filterRequest Search request content. Supported keys:
      *                                - searchtags: list of tags
      *                                - searchterm: term search
-     * @param bool   $casesensitive Optional: Perform case sensitive filter
-     * @param string $visibility    return only all/private/public links
-     * @param string $untaggedonly  return only untagged links
+     * @param bool $casesensitive Optional: Perform case sensitive filter
+     * @param string $visibility return only all/private/public links
+     * @param string $untaggedonly return only untagged links
      *
      * @return array filtered links, all links if no suitable filter was provided.
      */
@@ -432,6 +441,7 @@ You use the community supported version of the original Shaarli project, by Seba
         $visibility = 'all',
         $untaggedonly = false
     ) {
+    
         // Filter link database according to parameters.
         $searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
         $searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
@@ -448,7 +458,7 @@ You use the community supported version of the original Shaarli project, by Seba
      * Returns the list tags appearing in the links with the given tags
      *
      * @param array $filteringTags tags selecting the links to consider
-     * @param string $visibility   process only all/private/public links
+     * @param string $visibility process only all/private/public links
      *
      * @return array tag => linksCount
      */
@@ -490,7 +500,7 @@ You use the community supported version of the original Shaarli project, by Seba
      * Rename or delete a tag across all links.
      *
      * @param string $from Tag to rename
-     * @param string $to   New tag. If none is provided, the from tag will be deleted
+     * @param string $to New tag. If none is provided, the from tag will be deleted
      *
      * @return array|bool List of altered links or false on error
      */
index 1c51ac7397569011a8914abecfc180bbb33b26bb..d809bdd962ca901c54536309d17068652ff5f3bd 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 namespace Shaarli\Feed;
+
 /**
  * Simple cache system, mainly for the RSS/ATOM feeds
  */
index dcfd2c89d62f297c618ab0ff7198d7842445118b..737a31289b2500ae3cad55307ed1fdcf1202ab63 100644 (file)
@@ -2,7 +2,7 @@
 namespace Shaarli\Feed;
 
 use DateTime;
-use LinkDB;
+use Shaarli\Bookmark\LinkDB;
 
 /**
  * FeedBuilder class.
@@ -32,7 +32,7 @@ class FeedBuilder
     public static $DEFAULT_NB_LINKS = 50;
 
     /**
-     * @var LinkDB instance.
+     * @var \Shaarli\Bookmark\LinkDB instance.
      */
     protected $linkDB;
 
@@ -79,11 +79,12 @@ class FeedBuilder
     /**
      * Feed constructor.
      *
-     * @param LinkDB  $linkDB     LinkDB instance.
-     * @param string  $feedType   Type of feed.
-     * @param array   $serverInfo $_SERVER.
-     * @param array   $userInput  $_GET.
-     * @param boolean $isLoggedIn True if the user is currently logged in, false otherwise.
+     * @param \Shaarli\Bookmark\LinkDB $linkDB     LinkDB instance.
+     * @param string                   $feedType   Type of feed.
+     * @param array                    $serverInfo $_SERVER.
+     * @param array                    $userInput  $_GET.
+     * @param boolean                  $isLoggedIn True if the user is currently logged in,
+     *                                             false otherwise.
      */
     public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn)
     {
index 1df95bfb60d243d989debc0523546c4e8c79eab4..9a0fe61a557654f77ceeb5fae9dccec2f59171d2 100644 (file)
@@ -4,7 +4,7 @@ namespace Shaarli\Render;
 
 use ApplicationUtils;
 use Exception;
-use LinkDB;
+use Shaarli\Bookmark\LinkDB;
 use RainTPL;
 use Shaarli\Config\ConfigManager;
 use Shaarli\Thumbnailer;
index 422a3a4ed6e701077f76a065ab9784d7e1b520e0..e8dc2eb13c919c96258876e0d255e8493a5bac04 100644 (file)
@@ -35,6 +35,7 @@
             "Shaarli\\Api\\": "application/api/",
             "Shaarli\\Api\\Controllers\\": "application/api/controllers",
             "Shaarli\\Api\\Exceptions\\": "application/api/exceptions",
+            "Shaarli\\Bookmark\\": "application/bookmark",
             "Shaarli\\Config\\": "application/config/",
             "Shaarli\\Config\\Exception\\": "application/config/exception",
             "Shaarli\\Exceptions\\": "application/exceptions",
index 719b622cd90ece5a89f33fc8796b29fc6d877c68..b1d37a01cf1d83fd0c55e68b8020176060f7593f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -63,7 +63,6 @@ require_once 'application/http/HttpUtils.php';
 require_once 'application/http/UrlUtils.php';
 require_once 'application/FileUtils.php';
 require_once 'application/History.php';
-require_once 'application/LinkDB.php';
 require_once 'application/LinkFilter.php';
 require_once 'application/LinkUtils.php';
 require_once 'application/NetscapeBookmarkUtils.php';
@@ -72,6 +71,8 @@ require_once 'application/Utils.php';
 require_once 'application/PluginManager.php';
 require_once 'application/Router.php';
 require_once 'application/Updater.php';
+
+use \Shaarli\Bookmark\LinkDB;
 use \Shaarli\Config\ConfigManager;
 use \Shaarli\Feed\CachedPage;
 use \Shaarli\Feed\FeedBuilder;
index eb54c3591af12fb6111389d34d55b5979149bc10..db28b1c4fec7cd275b0d4937eb6230aaa8723d78 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Shaarli\Bookmark\LinkDB;
+
 require_once 'application/LinkFilter.php';
 
 /**
index 77fbd5f38795ee6bf8d1761e1a00da77922be9ae..adf854c59df90b114cc2592940aeed2d9930f44d 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Shaarli\Bookmark\LinkDB;
+
 require_once 'application/NetscapeBookmarkUtils.php';
 
 /**
index 07411c85cfd7b0faa3c6f173ae1285ddeb775c13..98c989bcebfa67d27ab990fd15cba7726e038535 100644 (file)
@@ -2,6 +2,7 @@
 
 require_once 'application/NetscapeBookmarkUtils.php';
 
+use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigManager;
 use Shaarli\History;
 
index a805ab5e900181755191e46b2dbe82b2f3c9e2dd..3c74b4ffda34388e1d83c15d9d64e0e6cbbdff45 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Shaarli\Bookmark\LinkDB;
+
 require_once 'application/Updater.php';
 
 /**
index c4a6e7ef4fee86c9634e9aaff4cfdc7f6f8d03d7..f910e05499168d174266853d7b584320a3827916 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+
+use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigJson;
 use Shaarli\Config\ConfigManager;
 use Shaarli\Config\ConfigPhp;
index e437082a1af9517b9b658498a07bed89ff9459c8..44a9382e847381196d52e5c28393ba056760907e 100644 (file)
@@ -53,7 +53,7 @@ class InfoTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = null;
 
         $this->controller = new Info($this->container);
index 07371e7abc27f0138cef87423df96cdbdeec8e67..adca9a4e71ea7df4c1a60b771678a776533aa35b 100644 (file)
@@ -32,7 +32,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
     protected $refDB = null;
 
     /**
-     * @var \LinkDB instance.
+     * @var \Shaarli\Bookmark\LinkDB instance.
      */
     protected $linkDB;
 
@@ -59,7 +59,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
         $this->conf = new ConfigManager('tests/utils/config/configJson');
         $this->refDB = new \ReferenceLinkDB();
         $this->refDB->write(self::$testDatastore);
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $refHistory = new \ReferenceHistory();
         $refHistory->write(self::$testHistory);
         $this->history = new \Shaarli\History(self::$testHistory);
@@ -96,7 +96,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(204, $response->getStatusCode());
         $this->assertEmpty((string) $response->getBody());
 
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->assertFalse(isset($this->linkDB[$id]));
 
         $historyEntry = $this->history->getHistory()[0];
index 57528d5aee7c7372dee4dff3fd6f15abe0a6d8af..bf58000b46138d51f34eb22b3ccec94e8982814d 100644 (file)
@@ -61,7 +61,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = null;
 
         $this->controller = new Links($this->container);
@@ -108,7 +108,7 @@ class GetLinkIdTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('sTuff', $data['tags'][0]);
         $this->assertEquals(false, $data['private']);
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
             $data['created']
         );
         $this->assertEmpty($data['updated']);
index 64f027743787d22fd7ad9a700145c4e6563ba6e7..1008d7b2e941138675bff4fb93227b0dd19d0b0e 100644 (file)
@@ -60,7 +60,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = null;
 
         $this->controller = new Links($this->container);
@@ -114,7 +114,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('sTuff', $first['tags'][0]);
         $this->assertEquals(false, $first['private']);
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
             $first['created']
         );
         $this->assertEmpty($first['updated']);
@@ -125,7 +125,7 @@ class GetLinksTest extends \PHPUnit_Framework_TestCase
 
         // Update date
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM),
             $link['updated']
         );
     }
index a73f443c47789dd9db5f5f93362e6ca43198880a..ade07eeb39adedc07b3faca3be07bad79459143b 100644 (file)
@@ -74,7 +74,7 @@ class PostLinkTest extends TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = new \Shaarli\History(self::$testHistory);
 
         $this->controller = new Links($this->container);
@@ -210,11 +210,11 @@ class PostLinkTest extends TestCase
         $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
         $this->assertEquals(false, $data['private']);
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
             \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
         );
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
             \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
         );
     }
index 3bb4d43f7f17dd7c5c45dbcaf413ffd16515b63c..eb6c7955c83065f5b44f3a824779090882a81a1e 100644 (file)
@@ -66,7 +66,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = new \Shaarli\History(self::$testHistory);
 
         $this->controller = new Links($this->container);
@@ -198,11 +198,11 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(['gnu', 'media', 'web', '.hidden', 'hashtag'], $data['tags']);
         $this->assertEquals(false, $data['private']);
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130614_184135'),
             \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
         );
         $this->assertEquals(
-            \DateTime::createFromFormat(\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
+            \DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20130615_184230'),
             \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
         );
     }
index a1e419cda1a767bd3f5295ebe27d895be574fd0d..02803ba2c9456173da1f376586e6a96e329d4ec4 100644 (file)
@@ -32,7 +32,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
     protected $refDB = null;
 
     /**
-     * @var \LinkDB instance.
+     * @var \Shaarli\Bookmark\LinkDB instance.
      */
     protected $linkDB;
 
@@ -59,7 +59,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
         $this->conf = new ConfigManager('tests/utils/config/configJson');
         $this->refDB = new \ReferenceLinkDB();
         $this->refDB->write(self::$testDatastore);
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $refHistory = new \ReferenceHistory();
         $refHistory->write(self::$testHistory);
         $this->history = new \Shaarli\History(self::$testHistory);
@@ -97,7 +97,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(204, $response->getStatusCode());
         $this->assertEmpty((string) $response->getBody());
 
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $tags = $this->linkDB->linksCountPerTag();
         $this->assertFalse(isset($tags[$tagName]));
 
@@ -131,7 +131,7 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(204, $response->getStatusCode());
         $this->assertEmpty((string) $response->getBody());
 
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $tags = $this->linkDB->linksCountPerTag();
         $this->assertFalse(isset($tags[$tagName]));
         $this->assertTrue($tags[strtolower($tagName)] > 0);
index afac228e26b23e0ad74037c105e69a5a4b49a67c..8e0feccd32a271ef01580159a5e26e3d9d4b6056 100644 (file)
@@ -59,7 +59,7 @@ class GetTagNameTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->container['db'] = new \LinkDB(self::$testDatastore, true, false);
+        $this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['history'] = null;
 
         $this->controller = new Tags($this->container);
index 3fab31b0f462a3ee335b9429240e65919a745e68..f071bfa8fded76998d91ab0e972f7380b29af922 100644 (file)
@@ -38,7 +38,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase
     protected $container;
 
     /**
-     * @var \LinkDB instance.
+     * @var \Shaarli\Bookmark\LinkDB instance.
      */
     protected $linkDB;
 
@@ -63,7 +63,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['db'] = $this->linkDB;
         $this->container['history'] = null;
 
index c45fa7222a46426f71e56540e8327e7d4913cb20..d8c0fec86fe5b7c120e57b00a18c519a274baeee 100644 (file)
@@ -43,7 +43,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
     protected $container;
 
     /**
-     * @var \LinkDB instance.
+     * @var \Shaarli\Bookmark\LinkDB instance.
      */
     protected $linkDB;
 
@@ -72,7 +72,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
 
         $this->container = new Container();
         $this->container['conf'] = $this->conf;
-        $this->linkDB = new \LinkDB(self::$testDatastore, true, false);
+        $this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false);
         $this->container['db'] = $this->linkDB;
         $this->container['history'] = $this->history;
 
similarity index 97%
rename from tests/LinkDBTest.php
rename to tests/bookmark/LinkDBTest.php
index 737a2247d03bd7404a9c9ca27961aecd79f596f1..f18a3155bd060efdf0477dd7150cc6126176a614 100644 (file)
@@ -3,9 +3,15 @@
  * Link datastore tests
  */
 
+namespace Shaarli\Bookmark;
+
+use DateTime;
+use LinkNotFoundException;
+use ReferenceLinkDB;
+use ReflectionClass;
+use Shaarli;
+
 require_once 'application/feed/Cache.php';
-require_once 'application/FileUtils.php';
-require_once 'application/LinkDB.php';
 require_once 'application/Utils.php';
 require_once 'tests/utils/ReferenceLinkDB.php';
 
@@ -13,7 +19,7 @@ require_once 'tests/utils/ReferenceLinkDB.php';
 /**
  * Unitary tests for LinkDB
  */
-class LinkDBTest extends PHPUnit_Framework_TestCase
+class LinkDBTest extends \PHPUnit\Framework\TestCase
 {
     // datastore to test write operations
     protected static $testDatastore = 'sandbox/datastore.php';
@@ -73,7 +79,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
      */
     protected static function getMethod($name)
     {
-        $class = new ReflectionClass('LinkDB');
+        $class = new ReflectionClass('Shaarli\Bookmark\LinkDB');
         $method = $class->getMethod($name);
         $method->setAccessible(true);
         return $method;
@@ -187,12 +193,12 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
 
         $link = array(
             'id' => 42,
-            'title'=>'an additional link',
-            'url'=>'http://dum.my',
-            'description'=>'One more',
-            'private'=>0,
-            'created'=> DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'),
-            'tags'=>'unit test'
+            'title' => 'an additional link',
+            'url' => 'http://dum.my',
+            'description' => 'One more',
+            'private' => 0,
+            'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'),
+            'tags' => 'unit test'
         );
         $testDB[$link['id']] = $link;
         $testDB->save('tests');
index 1fdbc60e3816b340efc202ffc25383d1e94c3f9e..88d1c3ed7d05dd9110db3444e000019f8b977740 100644 (file)
@@ -3,11 +3,9 @@
 namespace Shaarli\Feed;
 
 use DateTime;
-use LinkDB;
+use Shaarli\Bookmark\LinkDB;
 use ReferenceLinkDB;
 
-require_once 'application/LinkDB.php';
-
 /**
  * FeedBuilderTest class.
  *
index 342b78a43b3b41c602a192905aacc59975fe078c..ae92f73a4d4a2a62a851b9d99d5b523bc9b303e7 100644 (file)
@@ -5,7 +5,6 @@
 
 namespace Shaarli\Http;
 
-
 /**
  * Unitary tests for URL utilities
  */
index 2c9efbcde4292a221392a725d73d488dd26c2c9e..f5fa1daacbc81f5ed3296b811e060d2f2e63a87c 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+
+use Shaarli\Bookmark\LinkDB;
 use Shaarli\Config\ConfigManager;
 
 require_once 'plugins/isso/isso.php';
index 59679e380f8d59b8e959d5773b941ec9b68b3a65..c12bcb678e42bf8de317e5308bd5a9251613ec59 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Shaarli\Bookmark\LinkDB;
+
 /**
  * Populates a reference datastore to test LinkDB
  */