namespacing: \Shaarli\Bookmark\LinkDB
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
a0c4dbd91c
commit
f24896b237
32 changed files with 115 additions and 77 deletions
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
/**
|
||||
* Class LinkFilter.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
/**
|
||||
* Get cURL callback function for CURLOPT_WRITEFUNCTION
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Psr\Log\LogLevel;
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigJson;
|
||||
use Shaarli\Config\ConfigPhp;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
|
|
@ -127,7 +127,7 @@ protected function checkToken($request)
|
|||
*/
|
||||
protected function setLinkDb($conf)
|
||||
{
|
||||
$linkDb = new \LinkDB(
|
||||
$linkDb = new \Shaarli\Bookmark\LinkDB(
|
||||
$conf->get('resource.datastore'),
|
||||
true,
|
||||
$conf->get('privacy.hide_public_links'),
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract class ApiController
|
|||
protected $conf;
|
||||
|
||||
/**
|
||||
* @var \LinkDB
|
||||
* @var \Shaarli\Bookmark\LinkDB
|
||||
*/
|
||||
protected $linkDb;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -112,6 +120,7 @@ public function __construct(
|
|||
$redirector = '',
|
||||
$redirectorEncode = true
|
||||
) {
|
||||
|
||||
$this->datastore = $datastore;
|
||||
$this->loggedIn = $isLoggedIn;
|
||||
$this->hidePublicLinks = $hidePublicLinks;
|
||||
|
@ -432,6 +441,7 @@ public function filterSearch(
|
|||
$visibility = 'all',
|
||||
$untaggedonly = false
|
||||
) {
|
||||
|
||||
// Filter link database according to parameters.
|
||||
$searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
|
||||
$searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Feed;
|
||||
|
||||
/**
|
||||
* Simple cache system, mainly for the RSS/ATOM feeds
|
||||
*/
|
||||
|
|
|
@ -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 \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.
|
||||
* @param boolean $isLoggedIn True if the user is currently logged in,
|
||||
* false otherwise.
|
||||
*/
|
||||
public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use ApplicationUtils;
|
||||
use Exception;
|
||||
use LinkDB;
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use RainTPL;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Thumbnailer;
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
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/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;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
require_once 'application/LinkFilter.php';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
require_once 'application/NetscapeBookmarkUtils.php';
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require_once 'application/NetscapeBookmarkUtils.php';
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
require_once 'application/Updater.php';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigJson;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Config\ConfigPhp;
|
||||
|
|
|
@ -53,7 +53,7 @@ public function setUp()
|
|||
|
||||
$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);
|
||||
|
|
|
@ -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 @@ public function setUp()
|
|||
$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 @@ public function testDeleteLinkValid()
|
|||
$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];
|
||||
|
|
|
@ -61,7 +61,7 @@ public function setUp()
|
|||
|
||||
$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 @@ public function testGetLinkId()
|
|||
$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']);
|
||||
|
|
|
@ -60,7 +60,7 @@ public function setUp()
|
|||
|
||||
$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 @@ public function testGetLinks()
|
|||
$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 @@ public function testGetLinks()
|
|||
|
||||
// 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']
|
||||
);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public function setUp()
|
|||
|
||||
$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 @@ public function testPostLinkDuplicate()
|
|||
$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'])
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public function setUp()
|
|||
|
||||
$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 @@ public function testPutLinkDuplicate()
|
|||
$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'])
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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 @@ public function setUp()
|
|||
$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 @@ public function testDeleteTagValid()
|
|||
$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 @@ public function testDeleteTagCaseSensitivity()
|
|||
$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);
|
||||
|
|
|
@ -59,7 +59,7 @@ public function setUp()
|
|||
|
||||
$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);
|
||||
|
|
|
@ -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 @@ public function setUp()
|
|||
|
||||
$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;
|
||||
|
||||
|
|
|
@ -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 @@ public function setUp()
|
|||
|
||||
$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;
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
/**
|
||||
* 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 @@ protected function setUp()
|
|||
*/
|
||||
protected static function getMethod($name)
|
||||
{
|
||||
$class = new ReflectionClass('LinkDB');
|
||||
$class = new ReflectionClass('Shaarli\Bookmark\LinkDB');
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
return $method;
|
|
@ -3,11 +3,9 @@
|
|||
namespace Shaarli\Feed;
|
||||
|
||||
use DateTime;
|
||||
use LinkDB;
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use ReferenceLinkDB;
|
||||
|
||||
require_once 'application/LinkDB.php';
|
||||
|
||||
/**
|
||||
* FeedBuilderTest class.
|
||||
*
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace Shaarli\Http;
|
||||
|
||||
|
||||
/**
|
||||
* Unitary tests for URL utilities
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
||||
require_once 'plugins/isso/isso.php';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
|
||||
/**
|
||||
* Populates a reference datastore to test LinkDB
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue