From dea72c711ff740b3b829d238fcf85648465143a0 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 12 Jan 2019 23:55:38 +0100 Subject: Optimize and cleanup imports Signed-off-by: VirtualTam --- application/Languages.php | 1 - application/Thumbnailer.php | 2 +- application/api/ApiMiddleware.php | 3 +- application/api/ApiUtils.php | 2 +- application/api/controllers/ApiController.php | 7 ++- application/api/controllers/History.php | 69 ---------------------- application/api/controllers/HistoryController.php | 69 ++++++++++++++++++++++ application/api/controllers/Tags.php | 1 - .../api/exceptions/ApiLinkNotFoundException.php | 2 - .../api/exceptions/ApiTagNotFoundException.php | 2 - application/bookmark/LinkDB.php | 1 - application/feed/FeedBuilder.php | 1 - application/netscape/NetscapeBookmarkUtils.php | 2 +- application/render/PageBuilder.php | 4 +- application/updater/Updater.php | 2 +- tests/LanguagesTest.php | 2 +- tests/TimeZoneTest.php | 2 +- tests/UtilsTest.php | 2 +- tests/api/ApiMiddlewareTest.php | 3 +- tests/api/ApiUtilsTest.php | 2 +- tests/api/controllers/history/HistoryTest.php | 28 ++++----- tests/api/controllers/info/InfoTest.php | 3 +- tests/api/controllers/links/DeleteLinkTest.php | 18 +++--- tests/api/controllers/links/GetLinkIdTest.php | 3 +- tests/api/controllers/links/GetLinksTest.php | 10 ++-- tests/api/controllers/links/PostLinkTest.php | 9 +-- tests/api/controllers/links/PutLinkTest.php | 11 ++-- tests/api/controllers/tags/DeleteTagTest.php | 22 +++---- tests/api/controllers/tags/GetTagNameTest.php | 6 +- tests/api/controllers/tags/GetTagsTest.php | 8 +-- tests/api/controllers/tags/PutTagTest.php | 17 +++--- tests/bookmark/LinkDBTest.php | 1 - tests/config/ConfigJsonTest.php | 2 +- tests/config/ConfigManagerTest.php | 2 +- tests/config/ConfigPhpTest.php | 2 +- tests/config/ConfigPluginTest.php | 2 +- tests/feed/FeedBuilderTest.php | 2 +- tests/languages/fr/LanguagesFrTest.php | 2 +- tests/plugins/WallabagInstanceTest.php | 2 - tests/render/ThemeUtilsTest.php | 2 +- tests/security/LoginManagerTest.php | 3 +- tests/security/SessionManagerTest.php | 4 +- 42 files changed, 166 insertions(+), 172 deletions(-) delete mode 100644 application/api/controllers/History.php create mode 100644 application/api/controllers/HistoryController.php diff --git a/application/Languages.php b/application/Languages.php index b9c5d0e8..5cda802e 100644 --- a/application/Languages.php +++ b/application/Languages.php @@ -3,7 +3,6 @@ namespace Shaarli; use Gettext\GettextTranslator; -use Gettext\Merge; use Gettext\Translations; use Gettext\Translator; use Gettext\TranslatorInterface; diff --git a/application/Thumbnailer.php b/application/Thumbnailer.php index 37ed97a1..a23f98e9 100644 --- a/application/Thumbnailer.php +++ b/application/Thumbnailer.php @@ -3,9 +3,9 @@ namespace Shaarli; use Shaarli\Config\ConfigManager; +use WebThumbnailer\Application\ConfigManager as WTConfigManager; use WebThumbnailer\Exception\WebThumbnailerException; use WebThumbnailer\WebThumbnailer; -use WebThumbnailer\Application\ConfigManager as WTConfigManager; /** * Class Thumbnailer diff --git a/application/api/ApiMiddleware.php b/application/api/ApiMiddleware.php index a2101f29..5ffb8c6d 100644 --- a/application/api/ApiMiddleware.php +++ b/application/api/ApiMiddleware.php @@ -1,9 +1,8 @@ history->getHistory(); - - // Return history operations from the {offset}th, starting from {since}. - $since = \DateTime::createFromFormat(\DateTime::ATOM, $request->getParam('since')); - $offset = $request->getParam('offset'); - if (empty($offset)) { - $offset = 0; - } elseif (ctype_digit($offset)) { - $offset = (int) $offset; - } else { - throw new ApiBadParametersException('Invalid offset'); - } - - // limit parameter is either a number of links or 'all' for everything. - $limit = $request->getParam('limit'); - if (empty($limit)) { - $limit = count($history); - } elseif (ctype_digit($limit)) { - $limit = (int) $limit; - } else { - throw new ApiBadParametersException('Invalid limit'); - } - - $out = []; - $i = 0; - foreach ($history as $entry) { - if ((! empty($since) && $entry['datetime'] <= $since) || count($out) >= $limit) { - break; - } - if (++$i > $offset) { - $out[$i] = $entry; - $out[$i]['datetime'] = $out[$i]['datetime']->format(\DateTime::ATOM); - } - } - $out = array_values($out); - - return $response->withJson($out, 200, $this->jsonStyle); - } -} diff --git a/application/api/controllers/HistoryController.php b/application/api/controllers/HistoryController.php new file mode 100644 index 00000000..9afcfa26 --- /dev/null +++ b/application/api/controllers/HistoryController.php @@ -0,0 +1,69 @@ +history->getHistory(); + + // Return history operations from the {offset}th, starting from {since}. + $since = \DateTime::createFromFormat(\DateTime::ATOM, $request->getParam('since')); + $offset = $request->getParam('offset'); + if (empty($offset)) { + $offset = 0; + } elseif (ctype_digit($offset)) { + $offset = (int) $offset; + } else { + throw new ApiBadParametersException('Invalid offset'); + } + + // limit parameter is either a number of links or 'all' for everything. + $limit = $request->getParam('limit'); + if (empty($limit)) { + $limit = count($history); + } elseif (ctype_digit($limit)) { + $limit = (int) $limit; + } else { + throw new ApiBadParametersException('Invalid limit'); + } + + $out = []; + $i = 0; + foreach ($history as $entry) { + if ((! empty($since) && $entry['datetime'] <= $since) || count($out) >= $limit) { + break; + } + if (++$i > $offset) { + $out[$i] = $entry; + $out[$i]['datetime'] = $out[$i]['datetime']->format(\DateTime::ATOM); + } + } + $out = array_values($out); + + return $response->withJson($out, 200, $this->jsonStyle); + } +} diff --git a/application/api/controllers/Tags.php b/application/api/controllers/Tags.php index 6dd78750..82f3ef74 100644 --- a/application/api/controllers/Tags.php +++ b/application/api/controllers/Tags.php @@ -4,7 +4,6 @@ namespace Shaarli\Api\Controllers; use Shaarli\Api\ApiUtils; use Shaarli\Api\Exceptions\ApiBadParametersException; -use Shaarli\Api\Exceptions\ApiLinkNotFoundException; use Shaarli\Api\Exceptions\ApiTagNotFoundException; use Slim\Http\Request; use Slim\Http\Response; diff --git a/application/api/exceptions/ApiLinkNotFoundException.php b/application/api/exceptions/ApiLinkNotFoundException.php index c727f4f0..7c2bb56e 100644 --- a/application/api/exceptions/ApiLinkNotFoundException.php +++ b/application/api/exceptions/ApiLinkNotFoundException.php @@ -2,8 +2,6 @@ namespace Shaarli\Api\Exceptions; -use Slim\Http\Response; - /** * Class ApiLinkNotFoundException * diff --git a/application/api/exceptions/ApiTagNotFoundException.php b/application/api/exceptions/ApiTagNotFoundException.php index eee152fe..66ace8bf 100644 --- a/application/api/exceptions/ApiTagNotFoundException.php +++ b/application/api/exceptions/ApiTagNotFoundException.php @@ -2,8 +2,6 @@ namespace Shaarli\Api\Exceptions; -use Slim\Http\Response; - /** * Class ApiTagNotFoundException * diff --git a/application/bookmark/LinkDB.php b/application/bookmark/LinkDB.php index 6041c088..c13a1141 100644 --- a/application/bookmark/LinkDB.php +++ b/application/bookmark/LinkDB.php @@ -6,7 +6,6 @@ use ArrayAccess; use Countable; use DateTime; use Iterator; -use Shaarli\Bookmark\LinkFilter; use Shaarli\Bookmark\Exception\LinkNotFoundException; use Shaarli\Exceptions\IOException; use Shaarli\FileUtils; diff --git a/application/feed/FeedBuilder.php b/application/feed/FeedBuilder.php index 737a3128..b66f2f91 100644 --- a/application/feed/FeedBuilder.php +++ b/application/feed/FeedBuilder.php @@ -2,7 +2,6 @@ namespace Shaarli\Feed; use DateTime; -use Shaarli\Bookmark\LinkDB; /** * FeedBuilder class. diff --git a/application/netscape/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php index 2bf928c2..2fb1a4a6 100644 --- a/application/netscape/NetscapeBookmarkUtils.php +++ b/application/netscape/NetscapeBookmarkUtils.php @@ -5,12 +5,12 @@ namespace Shaarli\Netscape; use DateTime; use DateTimeZone; use Exception; +use Katzgrau\KLogger\Logger; use Psr\Log\LogLevel; use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; use Shaarli\History; use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser; -use Katzgrau\KLogger\Logger; /** * Utilities to import and export bookmarks using the Netscape format diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 1c5b9251..0569b67f 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -2,10 +2,10 @@ namespace Shaarli\Render; -use Shaarli\ApplicationUtils; use Exception; -use Shaarli\Bookmark\LinkDB; use RainTPL; +use Shaarli\ApplicationUtils; +use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; use Shaarli\Thumbnailer; diff --git a/application/updater/Updater.php b/application/updater/Updater.php index 89f0ff7f..f12e3516 100644 --- a/application/updater/Updater.php +++ b/application/updater/Updater.php @@ -2,12 +2,12 @@ namespace Shaarli\Updater; -use Shaarli\ApplicationUtils; use Exception; use RainTPL; use ReflectionClass; use ReflectionException; use ReflectionMethod; +use Shaarli\ApplicationUtils; use Shaarli\Bookmark\LinkDB; use Shaarli\Bookmark\LinkFilter; use Shaarli\Config\ConfigJson; diff --git a/tests/LanguagesTest.php b/tests/LanguagesTest.php index 4951e09a..de83f291 100644 --- a/tests/LanguagesTest.php +++ b/tests/LanguagesTest.php @@ -7,7 +7,7 @@ use Shaarli\Config\ConfigManager; /** * Class LanguagesTest. */ -class LanguagesTest extends \PHPUnit_Framework_TestCase +class LanguagesTest extends \PHPUnit\Framework\TestCase { /** * @var string Config file path (without extension). diff --git a/tests/TimeZoneTest.php b/tests/TimeZoneTest.php index 127fdc19..02bf060f 100644 --- a/tests/TimeZoneTest.php +++ b/tests/TimeZoneTest.php @@ -8,7 +8,7 @@ require_once 'application/TimeZone.php'; /** * Unitary tests for timezone utilities */ -class TimeZoneTest extends PHPUnit_Framework_TestCase +class TimeZoneTest extends PHPUnit\Framework\TestCase { /** * @var array of timezones diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index d0abd996..8225d95a 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -10,7 +10,7 @@ require_once 'application/Languages.php'; /** * Unitary tests for Shaarli utilities */ -class UtilsTest extends PHPUnit_Framework_TestCase +class UtilsTest extends PHPUnit\Framework\TestCase { // Log file protected static $testLogFile = 'tests.log'; diff --git a/tests/api/ApiMiddlewareTest.php b/tests/api/ApiMiddlewareTest.php index 23a56b1c..0b9b03f2 100644 --- a/tests/api/ApiMiddlewareTest.php +++ b/tests/api/ApiMiddlewareTest.php @@ -2,7 +2,6 @@ namespace Shaarli\Api; use Shaarli\Config\ConfigManager; - use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -18,7 +17,7 @@ use Slim\Http\Response; * * @package Api */ -class ApiMiddlewareTest extends \PHPUnit_Framework_TestCase +class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations diff --git a/tests/api/ApiUtilsTest.php b/tests/api/ApiUtilsTest.php index a1b623d8..ea0ae500 100644 --- a/tests/api/ApiUtilsTest.php +++ b/tests/api/ApiUtilsTest.php @@ -7,7 +7,7 @@ use Shaarli\Http\Base64Url; /** * Class ApiUtilsTest */ -class ApiUtilsTest extends \PHPUnit_Framework_TestCase +class ApiUtilsTest extends \PHPUnit\Framework\TestCase { /** * Force the timezone for ISO datetimes. diff --git a/tests/api/controllers/history/HistoryTest.php b/tests/api/controllers/history/HistoryTest.php index 24efee89..e287f239 100644 --- a/tests/api/controllers/history/HistoryTest.php +++ b/tests/api/controllers/history/HistoryTest.php @@ -1,9 +1,9 @@ container = new Container(); $this->container['conf'] = $this->conf; $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 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->refHistory->count(), count($data)); - $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); + $this->assertEquals(History::DELETED, $data[0]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), $data[0]['datetime'] ); $this->assertEquals(124, $data[0]['id']); - $this->assertEquals(\Shaarli\History::SETTINGS, $data[1]['event']); + $this->assertEquals(History::SETTINGS, $data[1]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), $data[1]['datetime'] ); $this->assertNull($data[1]['id']); - $this->assertEquals(\Shaarli\History::UPDATED, $data[2]['event']); + $this->assertEquals(History::UPDATED, $data[2]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170301_121214')->format(\DateTime::ATOM), $data[2]['datetime'] ); $this->assertEquals(123, $data[2]['id']); - $this->assertEquals(\Shaarli\History::CREATED, $data[3]['event']); + $this->assertEquals(History::CREATED, $data[3]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170201_121214')->format(\DateTime::ATOM), $data[3]['datetime'] ); $this->assertEquals(124, $data[3]['id']); - $this->assertEquals(\Shaarli\History::CREATED, $data[4]['event']); + $this->assertEquals(History::CREATED, $data[4]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), $data[4]['datetime'] @@ -131,7 +131,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, count($data)); - $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); + $this->assertEquals(History::DELETED, $data[0]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), $data[0]['datetime'] @@ -156,7 +156,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, count($data)); - $this->assertEquals(\Shaarli\History::CREATED, $data[0]['event']); + $this->assertEquals(History::CREATED, $data[0]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170101_121212')->format(\DateTime::ATOM), $data[0]['datetime'] @@ -181,7 +181,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, count($data)); - $this->assertEquals(\Shaarli\History::DELETED, $data[0]['event']); + $this->assertEquals(History::DELETED, $data[0]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170303_121216')->format(\DateTime::ATOM), $data[0]['datetime'] @@ -206,7 +206,7 @@ class HistoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, count($data)); - $this->assertEquals(\Shaarli\History::SETTINGS, $data[0]['event']); + $this->assertEquals(History::SETTINGS, $data[0]['event']); $this->assertEquals( \DateTime::createFromFormat('Ymd_His', '20170302_121215')->format(\DateTime::ATOM), $data[0]['datetime'] diff --git a/tests/api/controllers/info/InfoTest.php b/tests/api/controllers/info/InfoTest.php index 44a9382e..e70d371b 100644 --- a/tests/api/controllers/info/InfoTest.php +++ b/tests/api/controllers/info/InfoTest.php @@ -2,7 +2,6 @@ namespace Shaarli\Api\Controllers; use Shaarli\Config\ConfigManager; - use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -15,7 +14,7 @@ use Slim\Http\Response; * * @package Api\Controllers */ -class InfoTest extends \PHPUnit_Framework_TestCase +class InfoTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations diff --git a/tests/api/controllers/links/DeleteLinkTest.php b/tests/api/controllers/links/DeleteLinkTest.php index adca9a4e..90193e28 100644 --- a/tests/api/controllers/links/DeleteLinkTest.php +++ b/tests/api/controllers/links/DeleteLinkTest.php @@ -3,13 +3,15 @@ namespace Shaarli\Api\Controllers; +use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; +use Shaarli\History; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; use Slim\Http\Response; -class DeleteLinkTest extends \PHPUnit_Framework_TestCase +class DeleteLinkTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations @@ -32,12 +34,12 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase protected $refDB = null; /** - * @var \Shaarli\Bookmark\LinkDB instance. + * @var LinkDB instance. */ protected $linkDB; /** - * @var \Shaarli\History instance. + * @var HistoryController instance. */ protected $history; @@ -59,10 +61,10 @@ 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 \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); + $this->linkDB = new LinkDB(self::$testDatastore, true, false); $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); $this->container = new Container(); $this->container['conf'] = $this->conf; $this->container['db'] = $this->linkDB; @@ -96,11 +98,11 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase $this->assertEquals(204, $response->getStatusCode()); $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])); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::DELETED, $historyEntry['event']); + $this->assertEquals(History::DELETED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); @@ -110,7 +112,7 @@ class DeleteLinkTest extends \PHPUnit_Framework_TestCase /** * Test DELETE link endpoint: reach not existing ID. * - * @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException + * @expectedException \Shaarli\Api\Exceptions\ApiLinkNotFoundException */ public function testDeleteLink404() { diff --git a/tests/api/controllers/links/GetLinkIdTest.php b/tests/api/controllers/links/GetLinkIdTest.php index bf58000b..cb9b7f6a 100644 --- a/tests/api/controllers/links/GetLinkIdTest.php +++ b/tests/api/controllers/links/GetLinkIdTest.php @@ -3,7 +3,6 @@ namespace Shaarli\Api\Controllers; use Shaarli\Config\ConfigManager; - use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -18,7 +17,7 @@ use Slim\Http\Response; * * @package Shaarli\Api\Controllers */ -class GetLinkIdTest extends \PHPUnit_Framework_TestCase +class GetLinkIdTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations diff --git a/tests/api/controllers/links/GetLinksTest.php b/tests/api/controllers/links/GetLinksTest.php index 1008d7b2..711a3152 100644 --- a/tests/api/controllers/links/GetLinksTest.php +++ b/tests/api/controllers/links/GetLinksTest.php @@ -1,8 +1,8 @@ container = new Container(); $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->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(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20150310_114651')->format(\DateTime::ATOM), + \DateTime::createFromFormat(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(\Shaarli\Bookmark\LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), + \DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20160803_093033')->format(\DateTime::ATOM), $link['updated'] ); } diff --git a/tests/api/controllers/links/PostLinkTest.php b/tests/api/controllers/links/PostLinkTest.php index 24e591db..d683a984 100644 --- a/tests/api/controllers/links/PostLinkTest.php +++ b/tests/api/controllers/links/PostLinkTest.php @@ -4,6 +4,7 @@ namespace Shaarli\Api\Controllers; use PHPUnit\Framework\TestCase; use Shaarli\Config\ConfigManager; +use Shaarli\History; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -40,7 +41,7 @@ class PostLinkTest extends TestCase protected $refDB = null; /** - * @var \Shaarli\History instance. + * @var HistoryController instance. */ protected $history; @@ -70,12 +71,12 @@ class PostLinkTest extends TestCase $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); $this->container = new Container(); $this->container['conf'] = $this->conf; $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); @@ -133,7 +134,7 @@ class PostLinkTest extends TestCase $this->assertEquals('', $data['updated']); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::CREATED, $historyEntry['event']); + $this->assertEquals(History::CREATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); diff --git a/tests/api/controllers/links/PutLinkTest.php b/tests/api/controllers/links/PutLinkTest.php index eb6c7955..cd815b66 100644 --- a/tests/api/controllers/links/PutLinkTest.php +++ b/tests/api/controllers/links/PutLinkTest.php @@ -4,12 +4,13 @@ namespace Shaarli\Api\Controllers; use Shaarli\Config\ConfigManager; +use Shaarli\History; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; use Slim\Http\Response; -class PutLinkTest extends \PHPUnit_Framework_TestCase +class PutLinkTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations @@ -32,7 +33,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase protected $refDB = null; /** - * @var \Shaarli\History instance. + * @var HistoryController instance. */ protected $history; @@ -62,12 +63,12 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); $this->container = new Container(); $this->container['conf'] = $this->conf; $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); @@ -119,7 +120,7 @@ class PutLinkTest extends \PHPUnit_Framework_TestCase ); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); diff --git a/tests/api/controllers/tags/DeleteTagTest.php b/tests/api/controllers/tags/DeleteTagTest.php index 02803ba2..84e1d56e 100644 --- a/tests/api/controllers/tags/DeleteTagTest.php +++ b/tests/api/controllers/tags/DeleteTagTest.php @@ -3,13 +3,15 @@ namespace Shaarli\Api\Controllers; +use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; +use Shaarli\History; use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; use Slim\Http\Response; -class DeleteTagTest extends \PHPUnit_Framework_TestCase +class DeleteTagTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations @@ -32,12 +34,12 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase protected $refDB = null; /** - * @var \Shaarli\Bookmark\LinkDB instance. + * @var LinkDB instance. */ protected $linkDB; /** - * @var \Shaarli\History instance. + * @var HistoryController instance. */ protected $history; @@ -59,10 +61,10 @@ 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 \Shaarli\Bookmark\LinkDB(self::$testDatastore, true, false); + $this->linkDB = new LinkDB(self::$testDatastore, true, false); $refHistory = new \ReferenceHistory(); $refHistory->write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); $this->container = new Container(); $this->container['conf'] = $this->conf; $this->container['db'] = $this->linkDB; @@ -97,18 +99,18 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase $this->assertEquals(204, $response->getStatusCode()); $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(); $this->assertFalse(isset($tags[$tagName])); // 2 links affected $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); $historyEntry = $this->history->getHistory()[1]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); @@ -131,13 +133,13 @@ class DeleteTagTest extends \PHPUnit_Framework_TestCase $this->assertEquals(204, $response->getStatusCode()); $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(); $this->assertFalse(isset($tags[$tagName])); $this->assertTrue($tags[strtolower($tagName)] > 0); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); diff --git a/tests/api/controllers/tags/GetTagNameTest.php b/tests/api/controllers/tags/GetTagNameTest.php index 8e0feccd..a2525c17 100644 --- a/tests/api/controllers/tags/GetTagNameTest.php +++ b/tests/api/controllers/tags/GetTagNameTest.php @@ -2,8 +2,8 @@ namespace Shaarli\Api\Controllers; +use Shaarli\Bookmark\LinkDB; use Shaarli\Config\ConfigManager; - use Slim\Container; use Slim\Http\Environment; use Slim\Http\Request; @@ -16,7 +16,7 @@ use Slim\Http\Response; * * @package Shaarli\Api\Controllers */ -class GetTagNameTest extends \PHPUnit_Framework_TestCase +class GetTagNameTest extends \PHPUnit\Framework\TestCase { /** * @var string datastore to test write operations @@ -59,7 +59,7 @@ class GetTagNameTest extends \PHPUnit_Framework_TestCase $this->container = new Container(); $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->controller = new Tags($this->container); diff --git a/tests/api/controllers/tags/GetTagsTest.php b/tests/api/controllers/tags/GetTagsTest.php index f071bfa8..98628c98 100644 --- a/tests/api/controllers/tags/GetTagsTest.php +++ b/tests/api/controllers/tags/GetTagsTest.php @@ -1,8 +1,8 @@ container = new Container(); $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['history'] = null; diff --git a/tests/api/controllers/tags/PutTagTest.php b/tests/api/controllers/tags/PutTagTest.php index d8c0fec8..86106fc7 100644 --- a/tests/api/controllers/tags/PutTagTest.php +++ b/tests/api/controllers/tags/PutTagTest.php @@ -1,16 +1,17 @@ write(self::$testHistory); - $this->history = new \Shaarli\History(self::$testHistory); + $this->history = new History(self::$testHistory); $this->container = new Container(); $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['history'] = $this->history; @@ -113,12 +114,12 @@ class PutTagTest extends \PHPUnit_Framework_TestCase $this->assertEquals(2, $tags[$newName]); $historyEntry = $this->history->getHistory()[0]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); $historyEntry = $this->history->getHistory()[1]; - $this->assertEquals(\Shaarli\History::UPDATED, $historyEntry['event']); + $this->assertEquals(History::UPDATED, $historyEntry['event']); $this->assertTrue( (new \DateTime())->add(\DateInterval::createFromDateString('-5 seconds')) < $historyEntry['datetime'] ); diff --git a/tests/bookmark/LinkDBTest.php b/tests/bookmark/LinkDBTest.php index 65409e95..ff5c0b97 100644 --- a/tests/bookmark/LinkDBTest.php +++ b/tests/bookmark/LinkDBTest.php @@ -6,7 +6,6 @@ namespace Shaarli\Bookmark; use DateTime; -use Shaarli\Bookmark\Exception\LinkNotFoundException; use ReferenceLinkDB; use ReflectionClass; use Shaarli; diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php index 99c1ea56..95ad060b 100644 --- a/tests/config/ConfigJsonTest.php +++ b/tests/config/ConfigJsonTest.php @@ -4,7 +4,7 @@ namespace Shaarli\Config; /** * Class ConfigJsonTest */ -class ConfigJsonTest extends \PHPUnit_Framework_TestCase +class ConfigJsonTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigJson diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php index 4a4e94ac..33830bc9 100644 --- a/tests/config/ConfigManagerTest.php +++ b/tests/config/ConfigManagerTest.php @@ -7,7 +7,7 @@ namespace Shaarli\Config; * Note: it only test the manager with ConfigJson, * 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 diff --git a/tests/config/ConfigPhpTest.php b/tests/config/ConfigPhpTest.php index be23eea1..67d878ce 100644 --- a/tests/config/ConfigPhpTest.php +++ b/tests/config/ConfigPhpTest.php @@ -4,7 +4,7 @@ namespace Shaarli\Config; /** * Class ConfigPhpTest */ -class ConfigPhpTest extends \PHPUnit_Framework_TestCase +class ConfigPhpTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigPhp diff --git a/tests/config/ConfigPluginTest.php b/tests/config/ConfigPluginTest.php index deb02c9e..d7a70e68 100644 --- a/tests/config/ConfigPluginTest.php +++ b/tests/config/ConfigPluginTest.php @@ -8,7 +8,7 @@ require_once 'application/config/ConfigPlugin.php'; /** * 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. diff --git a/tests/feed/FeedBuilderTest.php b/tests/feed/FeedBuilderTest.php index 88d1c3ed..b496cb4c 100644 --- a/tests/feed/FeedBuilderTest.php +++ b/tests/feed/FeedBuilderTest.php @@ -3,8 +3,8 @@ namespace Shaarli\Feed; use DateTime; -use Shaarli\Bookmark\LinkDB; use ReferenceLinkDB; +use Shaarli\Bookmark\LinkDB; /** * FeedBuilderTest class. diff --git a/tests/languages/fr/LanguagesFrTest.php b/tests/languages/fr/LanguagesFrTest.php index 38347de1..b8b7ca3a 100644 --- a/tests/languages/fr/LanguagesFrTest.php +++ b/tests/languages/fr/LanguagesFrTest.php @@ -12,7 +12,7 @@ use Shaarli\Config\ConfigManager; * * @package Shaarli */ -class LanguagesFrTest extends \PHPUnit_Framework_TestCase +class LanguagesFrTest extends \PHPUnit\Framework\TestCase { /** * @var string Config file path (without extension). diff --git a/tests/plugins/WallabagInstanceTest.php b/tests/plugins/WallabagInstanceTest.php index bcc01604..a3cd9076 100644 --- a/tests/plugins/WallabagInstanceTest.php +++ b/tests/plugins/WallabagInstanceTest.php @@ -1,8 +1,6 @@