Optimize and cleanup imports

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
VirtualTam 2019-01-12 23:55:38 +01:00
parent a43e7842e4
commit dea72c711f
41 changed files with 98 additions and 104 deletions

View file

@ -3,7 +3,6 @@
namespace Shaarli; namespace Shaarli;
use Gettext\GettextTranslator; use Gettext\GettextTranslator;
use Gettext\Merge;
use Gettext\Translations; use Gettext\Translations;
use Gettext\Translator; use Gettext\Translator;
use Gettext\TranslatorInterface; use Gettext\TranslatorInterface;

View file

@ -3,9 +3,9 @@
namespace Shaarli; namespace Shaarli;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use WebThumbnailer\Application\ConfigManager as WTConfigManager;
use WebThumbnailer\Exception\WebThumbnailerException; use WebThumbnailer\Exception\WebThumbnailerException;
use WebThumbnailer\WebThumbnailer; use WebThumbnailer\WebThumbnailer;
use WebThumbnailer\Application\ConfigManager as WTConfigManager;
/** /**
* Class Thumbnailer * Class Thumbnailer

View file

@ -1,9 +1,8 @@
<?php <?php
namespace Shaarli\Api; namespace Shaarli\Api;
use Shaarli\Api\Exceptions\ApiException;
use Shaarli\Api\Exceptions\ApiAuthorizationException; use Shaarli\Api\Exceptions\ApiAuthorizationException;
use Shaarli\Api\Exceptions\ApiException;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Request; use Slim\Http\Request;

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Shaarli\Api; namespace Shaarli\Api;
use Shaarli\Http\Base64Url;
use Shaarli\Api\Exceptions\ApiAuthorizationException; use Shaarli\Api\Exceptions\ApiAuthorizationException;
use Shaarli\Http\Base64Url;
/** /**
* REST API utilities * REST API utilities

View file

@ -2,8 +2,9 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use \Slim\Container; use Slim\Container;
/** /**
* Abstract Class ApiController * Abstract Class ApiController
@ -25,12 +26,12 @@ abstract class ApiController
protected $conf; protected $conf;
/** /**
* @var \Shaarli\Bookmark\LinkDB * @var LinkDB
*/ */
protected $linkDb; protected $linkDb;
/** /**
* @var \Shaarli\History * @var HistoryController
*/ */
protected $history; protected $history;

View file

@ -14,7 +14,7 @@
* *
* @package Shaarli\Api\Controllers * @package Shaarli\Api\Controllers
*/ */
class History extends ApiController class HistoryController extends ApiController
{ {
/** /**
* Service providing operation regarding Shaarli datastore and settings. * Service providing operation regarding Shaarli datastore and settings.

View file

@ -4,7 +4,6 @@
use Shaarli\Api\ApiUtils; use Shaarli\Api\ApiUtils;
use Shaarli\Api\Exceptions\ApiBadParametersException; use Shaarli\Api\Exceptions\ApiBadParametersException;
use Shaarli\Api\Exceptions\ApiLinkNotFoundException;
use Shaarli\Api\Exceptions\ApiTagNotFoundException; use Shaarli\Api\Exceptions\ApiTagNotFoundException;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;

View file

@ -2,8 +2,6 @@
namespace Shaarli\Api\Exceptions; namespace Shaarli\Api\Exceptions;
use Slim\Http\Response;
/** /**
* Class ApiLinkNotFoundException * Class ApiLinkNotFoundException
* *

View file

@ -2,8 +2,6 @@
namespace Shaarli\Api\Exceptions; namespace Shaarli\Api\Exceptions;
use Slim\Http\Response;
/** /**
* Class ApiTagNotFoundException * Class ApiTagNotFoundException
* *

View file

@ -6,7 +6,6 @@
use Countable; use Countable;
use DateTime; use DateTime;
use Iterator; use Iterator;
use Shaarli\Bookmark\LinkFilter;
use Shaarli\Bookmark\Exception\LinkNotFoundException; use Shaarli\Bookmark\Exception\LinkNotFoundException;
use Shaarli\Exceptions\IOException; use Shaarli\Exceptions\IOException;
use Shaarli\FileUtils; use Shaarli\FileUtils;

View file

@ -2,7 +2,6 @@
namespace Shaarli\Feed; namespace Shaarli\Feed;
use DateTime; use DateTime;
use Shaarli\Bookmark\LinkDB;
/** /**
* FeedBuilder class. * FeedBuilder class.

View file

@ -5,12 +5,12 @@
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
use Exception; use Exception;
use Katzgrau\KLogger\Logger;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
use Shaarli\Bookmark\LinkDB; use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History; use Shaarli\History;
use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;
use Katzgrau\KLogger\Logger;
/** /**
* Utilities to import and export bookmarks using the Netscape format * Utilities to import and export bookmarks using the Netscape format

View file

@ -2,10 +2,10 @@
namespace Shaarli\Render; namespace Shaarli\Render;
use Shaarli\ApplicationUtils;
use Exception; use Exception;
use Shaarli\Bookmark\LinkDB;
use RainTPL; use RainTPL;
use Shaarli\ApplicationUtils;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\Thumbnailer; use Shaarli\Thumbnailer;

View file

@ -2,12 +2,12 @@
namespace Shaarli\Updater; namespace Shaarli\Updater;
use Shaarli\ApplicationUtils;
use Exception; use Exception;
use RainTPL; use RainTPL;
use ReflectionClass; use ReflectionClass;
use ReflectionException; use ReflectionException;
use ReflectionMethod; use ReflectionMethod;
use Shaarli\ApplicationUtils;
use Shaarli\Bookmark\LinkDB; use Shaarli\Bookmark\LinkDB;
use Shaarli\Bookmark\LinkFilter; use Shaarli\Bookmark\LinkFilter;
use Shaarli\Config\ConfigJson; use Shaarli\Config\ConfigJson;

View file

@ -7,7 +7,7 @@
/** /**
* Class LanguagesTest. * Class LanguagesTest.
*/ */
class LanguagesTest extends \PHPUnit_Framework_TestCase class LanguagesTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string Config file path (without extension). * @var string Config file path (without extension).

View file

@ -8,7 +8,7 @@
/** /**
* Unitary tests for timezone utilities * Unitary tests for timezone utilities
*/ */
class TimeZoneTest extends PHPUnit_Framework_TestCase class TimeZoneTest extends PHPUnit\Framework\TestCase
{ {
/** /**
* @var array of timezones * @var array of timezones

View file

@ -10,7 +10,7 @@
/** /**
* Unitary tests for Shaarli utilities * Unitary tests for Shaarli utilities
*/ */
class UtilsTest extends PHPUnit_Framework_TestCase class UtilsTest extends PHPUnit\Framework\TestCase
{ {
// Log file // Log file
protected static $testLogFile = 'tests.log'; protected static $testLogFile = 'tests.log';

View file

@ -2,7 +2,6 @@
namespace Shaarli\Api; namespace Shaarli\Api;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -18,7 +17,7 @@
* *
* @package Api * @package Api
*/ */
class ApiMiddlewareTest extends \PHPUnit_Framework_TestCase class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations

View file

@ -7,7 +7,7 @@
/** /**
* Class ApiUtilsTest * Class ApiUtilsTest
*/ */
class ApiUtilsTest extends \PHPUnit_Framework_TestCase class ApiUtilsTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* Force the timezone for ISO datetimes. * Force the timezone for ISO datetimes.

View file

@ -1,9 +1,9 @@
<?php <?php
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -11,7 +11,7 @@
require_once 'tests/utils/ReferenceHistory.php'; require_once 'tests/utils/ReferenceHistory.php';
class HistoryTest extends \PHPUnit_Framework_TestCase class HistoryTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -34,7 +34,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
protected $container; protected $container;
/** /**
* @var History controller instance. * @var HistoryController controller instance.
*/ */
protected $controller; protected $controller;
@ -49,9 +49,9 @@ public function setUp()
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = true; $this->container['db'] = true;
$this->container['history'] = new \Shaarli\History(self::$testHistory); $this->container['history'] = new History(self::$testHistory);
$this->controller = new History($this->container); $this->controller = new HistoryController($this->container);
} }
/** /**
@ -78,35 +78,35 @@ public function testGetHistory()
$this->assertEquals($this->refHistory->count(), count($data)); $this->assertEquals($this->refHistory->count(), count($data));
$this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime'] $data[0]['datetime']
); );
$this->assertEquals(124, $data[0]['id']); $this->assertEquals(124, $data[0]['id']);
$this->assertEquals(\Shaarli\History::SETTINGS, $data[1]['event']); $this->assertEquals(History::SETTINGS, $data[1]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
$data[1]['datetime'] $data[1]['datetime']
); );
$this->assertNull($data[1]['id']); $this->assertNull($data[1]['id']);
$this->assertEquals(\Shaarli\History::UPDATED, $data[2]['event']); $this->assertEquals(History::UPDATED, $data[2]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM),
$data[2]['datetime'] $data[2]['datetime']
); );
$this->assertEquals(123, $data[2]['id']); $this->assertEquals(123, $data[2]['id']);
$this->assertEquals(\Shaarli\History::CREATED, $data[3]['event']); $this->assertEquals(History::CREATED, $data[3]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM),
$data[3]['datetime'] $data[3]['datetime']
); );
$this->assertEquals(124, $data[3]['id']); $this->assertEquals(124, $data[3]['id']);
$this->assertEquals(\Shaarli\History::CREATED, $data[4]['event']); $this->assertEquals(History::CREATED, $data[4]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
$data[4]['datetime'] $data[4]['datetime']
@ -131,7 +131,7 @@ public function testGetHistoryLimit()
$this->assertEquals(1, count($data)); $this->assertEquals(1, count($data));
$this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime'] $data[0]['datetime']
@ -156,7 +156,7 @@ public function testGetHistoryOffset()
$this->assertEquals(1, count($data)); $this->assertEquals(1, count($data));
$this->assertEquals(\Shaarli\History::CREATED, $data[0]['event']); $this->assertEquals(History::CREATED, $data[0]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM),
$data[0]['datetime'] $data[0]['datetime']
@ -181,7 +181,7 @@ public function testGetHistorySince()
$this->assertEquals(1, count($data)); $this->assertEquals(1, count($data));
$this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); $this->assertEquals(History::DELETED, $data[0]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM),
$data[0]['datetime'] $data[0]['datetime']
@ -206,7 +206,7 @@ public function testGetHistorySinceOffsetLimit()
$this->assertEquals(1, count($data)); $this->assertEquals(1, count($data));
$this->assertEquals(\Shaarli\History::SETTINGS, $data[0]['event']); $this->assertEquals(History::SETTINGS, $data[0]['event']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM),
$data[0]['datetime'] $data[0]['datetime']

View file

@ -2,7 +2,6 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -15,7 +14,7 @@
* *
* @package Api\Controllers * @package Api\Controllers
*/ */
class InfoTest extends \PHPUnit_Framework_TestCase class InfoTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations

View file

@ -3,13 +3,15 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
class DeleteLinkTest extends \PHPUnit_Framework_TestCase class DeleteLinkTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -32,12 +34,12 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase
protected $refDB = null; protected $refDB = null;
/** /**
* @var \Shaarli\Bookmark\LinkDB instance. * @var LinkDB instance.
*/ */
protected $linkDB; protected $linkDB;
/** /**
* @var \Shaarli\History instance. * @var HistoryController instance.
*/ */
protected $history; protected $history;
@ -59,10 +61,10 @@ public function setUp()
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refDB = new \ReferenceLinkDB(); $this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore); $this->refDB->write(self::$testDatastore);
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$refHistory = new \ReferenceHistory(); $refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory); $refHistory->write(self::$testHistory);
$this->history = new \Shaarli\History(self::$testHistory); $this->history = new History(self::$testHistory);
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = $this->linkDB; $this->container['db'] = $this->linkDB;
@ -96,11 +98,11 @@ public function testDeleteLinkValid()
$this->assertEquals(204, $response->getStatusCode()); $this->assertEquals(204, $response->getStatusCode());
$this->assertEmpty((string) $response->getBody()); $this->assertEmpty((string) $response->getBody());
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$this->assertFalse(isset($this->linkDB[$id])); $this->assertFalse(isset($this->linkDB[$id]));
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::DELETED, $historyEntry['event']); $this->assertEquals(History::DELETED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );
@ -110,7 +112,7 @@ public function testDeleteLinkValid()
/** /**
* Test DELETE link endpoint: reach not existing ID. * Test DELETE link endpoint: reach not existing ID.
* *
* @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException * @expectedException \Shaarli\Api\Exceptions\ApiLinkNotFoundException
*/ */
public function testDeleteLink404() public function testDeleteLink404()
{ {

View file

@ -3,7 +3,6 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -18,7 +17,7 @@
* *
* @package Shaarli\Api\Controllers * @package Shaarli\Api\Controllers
*/ */
class GetLinkIdTest extends \PHPUnit_Framework_TestCase class GetLinkIdTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -17,7 +17,7 @@
* *
* @package Shaarli\Api\Controllers * @package Shaarli\Api\Controllers
*/ */
class GetLinksTest extends \PHPUnit_Framework_TestCase class GetLinksTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -60,7 +60,7 @@ public function setUp()
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->container['db'] = new LinkDB(self::$testDatastore, true, false);
$this->container['history'] = null; $this->container['history'] = null;
$this->controller = new Links($this->container); $this->controller = new Links($this->container);
@ -114,7 +114,7 @@ public function testGetLinks()
$this->assertEquals('sTuff', $first['tags'][0]); $this->assertEquals('sTuff', $first['tags'][0]);
$this->assertEquals(false, $first['private']); $this->assertEquals(false, $first['private']);
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM),
$first['created'] $first['created']
); );
$this->assertEmpty($first['updated']); $this->assertEmpty($first['updated']);
@ -125,7 +125,7 @@ public function testGetLinks()
// Update date // Update date
$this->assertEquals( $this->assertEquals(
\DateTime::createFromFormat(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM),
$link['updated'] $link['updated']
); );
} }

View file

@ -4,6 +4,7 @@
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -40,7 +41,7 @@ class PostLinkTest extends TestCase
protected $refDB = null; protected $refDB = null;
/** /**
* @var \Shaarli\History instance. * @var HistoryController instance.
*/ */
protected $history; protected $history;
@ -70,12 +71,12 @@ public function setUp()
$refHistory = new \ReferenceHistory(); $refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory); $refHistory->write(self::$testHistory);
$this->history = new \Shaarli\History(self::$testHistory); $this->history = new History(self::$testHistory);
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = new \Shaarli\Bookmark\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->container['history'] = new History(self::$testHistory);
$this->controller = new Links($this->container); $this->controller = new Links($this->container);
@ -133,7 +134,7 @@ public function testPostLinkMinimal()
$this->assertEquals('', $data['updated']); $this->assertEquals('', $data['updated']);
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::CREATED, $historyEntry['event']); $this->assertEquals(History::CREATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );

View file

@ -4,12 +4,13 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
class PutLinkTest extends \PHPUnit_Framework_TestCase class PutLinkTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -32,7 +33,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase
protected $refDB = null; protected $refDB = null;
/** /**
* @var \Shaarli\History instance. * @var HistoryController instance.
*/ */
protected $history; protected $history;
@ -62,12 +63,12 @@ public function setUp()
$refHistory = new \ReferenceHistory(); $refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory); $refHistory->write(self::$testHistory);
$this->history = new \Shaarli\History(self::$testHistory); $this->history = new History(self::$testHistory);
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = new \Shaarli\Bookmark\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->container['history'] = new History(self::$testHistory);
$this->controller = new Links($this->container); $this->controller = new Links($this->container);
@ -119,7 +120,7 @@ public function testPutLinkMinimal()
); );
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );

View file

@ -3,13 +3,15 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
class DeleteTagTest extends \PHPUnit_Framework_TestCase class DeleteTagTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -32,12 +34,12 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase
protected $refDB = null; protected $refDB = null;
/** /**
* @var \Shaarli\Bookmark\LinkDB instance. * @var LinkDB instance.
*/ */
protected $linkDB; protected $linkDB;
/** /**
* @var \Shaarli\History instance. * @var HistoryController instance.
*/ */
protected $history; protected $history;
@ -59,10 +61,10 @@ public function setUp()
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refDB = new \ReferenceLinkDB(); $this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore); $this->refDB->write(self::$testDatastore);
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$refHistory = new \ReferenceHistory(); $refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory); $refHistory->write(self::$testHistory);
$this->history = new \Shaarli\History(self::$testHistory); $this->history = new History(self::$testHistory);
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = $this->linkDB; $this->container['db'] = $this->linkDB;
@ -97,18 +99,18 @@ public function testDeleteTagValid()
$this->assertEquals(204, $response->getStatusCode()); $this->assertEquals(204, $response->getStatusCode());
$this->assertEmpty((string) $response->getBody()); $this->assertEmpty((string) $response->getBody());
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$tags = $this->linkDB->linksCountPerTag(); $tags = $this->linkDB->linksCountPerTag();
$this->assertFalse(isset($tags[$tagName])); $this->assertFalse(isset($tags[$tagName]));
// 2 links affected // 2 links affected
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );
$historyEntry = $this->history->getHistory()[1]; $historyEntry = $this->history->getHistory()[1];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );
@ -131,13 +133,13 @@ public function testDeleteTagCaseSensitivity()
$this->assertEquals(204, $response->getStatusCode()); $this->assertEquals(204, $response->getStatusCode());
$this->assertEmpty((string) $response->getBody()); $this->assertEmpty((string) $response->getBody());
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$tags = $this->linkDB->linksCountPerTag(); $tags = $this->linkDB->linksCountPerTag();
$this->assertFalse(isset($tags[$tagName])); $this->assertFalse(isset($tags[$tagName]));
$this->assertTrue($tags[strtolower($tagName)] > 0); $this->assertTrue($tags[strtolower($tagName)] > 0);
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );

View file

@ -2,8 +2,8 @@
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -16,7 +16,7 @@
* *
* @package Shaarli\Api\Controllers * @package Shaarli\Api\Controllers
*/ */
class GetTagNameTest extends \PHPUnit_Framework_TestCase class GetTagNameTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -59,7 +59,7 @@ public function setUp()
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->container['db'] = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->container['db'] = new LinkDB(self::$testDatastore, true, false);
$this->container['history'] = null; $this->container['history'] = null;
$this->controller = new Tags($this->container); $this->controller = new Tags($this->container);

View file

@ -1,8 +1,8 @@
<?php <?php
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
@ -15,7 +15,7 @@
* *
* @package Shaarli\Api\Controllers * @package Shaarli\Api\Controllers
*/ */
class GetTagsTest extends \PHPUnit_Framework_TestCase class GetTagsTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -38,7 +38,7 @@ class GetTagsTest extends \PHPUnit_Framework_TestCase
protected $container; protected $container;
/** /**
* @var \Shaarli\Bookmark\LinkDB instance. * @var LinkDB instance.
*/ */
protected $linkDB; protected $linkDB;
@ -63,7 +63,7 @@ public function setUp()
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$this->container['db'] = $this->linkDB; $this->container['db'] = $this->linkDB;
$this->container['history'] = null; $this->container['history'] = null;

View file

@ -1,16 +1,17 @@
<?php <?php
namespace Shaarli\Api\Controllers; namespace Shaarli\Api\Controllers;
use Shaarli\Api\Exceptions\ApiBadParametersException; use Shaarli\Api\Exceptions\ApiBadParametersException;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Slim\Container; use Slim\Container;
use Slim\Http\Environment; use Slim\Http\Environment;
use Slim\Http\Request; use Slim\Http\Request;
use Slim\Http\Response; use Slim\Http\Response;
class PutTagTest extends \PHPUnit_Framework_TestCase class PutTagTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string datastore to test write operations * @var string datastore to test write operations
@ -33,7 +34,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
protected $refDB = null; protected $refDB = null;
/** /**
* @var \Shaarli\History instance. * @var HistoryController instance.
*/ */
protected $history; protected $history;
@ -43,7 +44,7 @@ class PutTagTest extends \PHPUnit_Framework_TestCase
protected $container; protected $container;
/** /**
* @var \Shaarli\Bookmark\LinkDB instance. * @var LinkDB instance.
*/ */
protected $linkDB; protected $linkDB;
@ -68,11 +69,11 @@ public function setUp()
$refHistory = new \ReferenceHistory(); $refHistory = new \ReferenceHistory();
$refHistory->write(self::$testHistory); $refHistory->write(self::$testHistory);
$this->history = new \Shaarli\History(self::$testHistory); $this->history = new History(self::$testHistory);
$this->container = new Container(); $this->container = new Container();
$this->container['conf'] = $this->conf; $this->container['conf'] = $this->conf;
$this->linkDB = new \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); $this->linkDB = new LinkDB(self::$testDatastore, true, false);
$this->container['db'] = $this->linkDB; $this->container['db'] = $this->linkDB;
$this->container['history'] = $this->history; $this->container['history'] = $this->history;
@ -113,12 +114,12 @@ public function testPutLinkValid()
$this->assertEquals(2, $tags[$newName]); $this->assertEquals(2, $tags[$newName]);
$historyEntry = $this->history->getHistory()[0]; $historyEntry = $this->history->getHistory()[0];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );
$historyEntry = $this->history->getHistory()[1]; $historyEntry = $this->history->getHistory()[1];
$this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); $this->assertEquals(History::UPDATED, $historyEntry['event']);
$this->assertTrue( $this->assertTrue(
(new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime']
); );

View file

@ -6,7 +6,6 @@
namespace Shaarli\Bookmark; namespace Shaarli\Bookmark;
use DateTime; use DateTime;
use Shaarli\Bookmark\Exception\LinkNotFoundException;
use ReferenceLinkDB; use ReferenceLinkDB;
use ReflectionClass; use ReflectionClass;
use Shaarli; use Shaarli;

View file

@ -4,7 +4,7 @@
/** /**
* Class ConfigJsonTest * Class ConfigJsonTest
*/ */
class ConfigJsonTest extends \PHPUnit_Framework_TestCase class ConfigJsonTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var ConfigJson * @var ConfigJson

View file

@ -7,7 +7,7 @@
* Note: it only test the manager with ConfigJson, * Note: it only test the manager with ConfigJson,
* ConfigPhp is only a workaround to handle the transition to JSON type. * ConfigPhp is only a workaround to handle the transition to JSON type.
*/ */
class ConfigManagerTest extends \PHPUnit_Framework_TestCase class ConfigManagerTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var ConfigManager * @var ConfigManager

View file

@ -4,7 +4,7 @@
/** /**
* Class ConfigPhpTest * Class ConfigPhpTest
*/ */
class ConfigPhpTest extends \PHPUnit_Framework_TestCase class ConfigPhpTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var ConfigPhp * @var ConfigPhp

View file

@ -8,7 +8,7 @@
/** /**
* Unitary tests for Shaarli config related functions * Unitary tests for Shaarli config related functions
*/ */
class ConfigPluginTest extends \PHPUnit_Framework_TestCase class ConfigPluginTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* Test save_plugin_config with valid data. * Test save_plugin_config with valid data.

View file

@ -3,8 +3,8 @@
namespace Shaarli\Feed; namespace Shaarli\Feed;
use DateTime; use DateTime;
use Shaarli\Bookmark\LinkDB;
use ReferenceLinkDB; use ReferenceLinkDB;
use Shaarli\Bookmark\LinkDB;
/** /**
* FeedBuilderTest class. * FeedBuilderTest class.

View file

@ -12,7 +12,7 @@
* *
* @package Shaarli * @package Shaarli
*/ */
class LanguagesFrTest extends \PHPUnit_Framework_TestCase class LanguagesFrTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* @var string Config file path (without extension). * @var string Config file path (without extension).

View file

@ -1,8 +1,6 @@
<?php <?php
namespace Shaarli\Plugin\Wallabag; namespace Shaarli\Plugin\Wallabag;
use Shaarli\Plugin\Wallabag\WallabagInstance;
/** /**
* Class WallabagInstanceTest * Class WallabagInstanceTest
*/ */

View file

@ -7,7 +7,7 @@
* *
* @package Shaarli * @package Shaarli
*/ */
class ThemeUtilsTest extends \PHPUnit_Framework_TestCase class ThemeUtilsTest extends \PHPUnit\Framework\TestCase
{ {
/** /**
* Test getThemes() with existing theme directories. * Test getThemes() with existing theme directories.

View file

@ -2,7 +2,8 @@
namespace Shaarli\Security; namespace Shaarli\Security;
require_once 'tests/utils/FakeConfigManager.php'; require_once 'tests/utils/FakeConfigManager.php';
use \PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestCase;
/** /**
* Test coverage for LoginManager * Test coverage for LoginManager

View file

@ -5,8 +5,8 @@
require_once 'tests/utils/ReferenceSessionIdHashes.php'; require_once 'tests/utils/ReferenceSessionIdHashes.php';
ReferenceSessionIdHashes::genAllHashes(); ReferenceSessionIdHashes::genAllHashes();
use \Shaarli\Security\SessionManager; use PHPUnit\Framework\TestCase;
use \PHPUnit\Framework\TestCase; use Shaarli\Security\SessionManager;
/** /**
* Test coverage for SessionManager * Test coverage for SessionManager