Coding style: manually fix remaining errors in tests after PHPCBF

Related to #95
This commit is contained in:
ArthurHoaro 2021-04-05 11:00:28 +02:00
parent 0681511699
commit 830a73dcf6
61 changed files with 243 additions and 194 deletions

View file

@ -71,5 +71,11 @@
"Shaarli\\Updater\\": "application/updater",
"Shaarli\\Updater\\Exception\\": "application/updater/exception"
}
},
"autoload-dev": {
"psr-4": {
"Shaarli\\Tests\\": "tests",
"Shaarli\\Tests\\Utils\\": "tests/utils"
}
}
}

View file

@ -19,5 +19,11 @@
<!-- index.php bootstraps everything, so yes mixed symbols with side effects -->
<exclude-pattern>index.php</exclude-pattern>
<exclude-pattern>plugins/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/utils/RainTPL.php</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>tests/utils/RainTPL.php</exclude-pattern>
</rule>
</ruleset>

View file

@ -15,9 +15,9 @@
*/
class ThumbnailerTest extends TestCase
{
const WIDTH = 190;
protected const WIDTH = 190;
const HEIGHT = 210;
protected const HEIGHT = 210;
/**
* @var Thumbnailer;

View file

@ -4,12 +4,14 @@
* TimeZone's tests
*/
require_once 'application/TimeZone.php';
namespace Shaarli\Tests;
use Shaarli\TestCase;
/**
* Unitary tests for timezone utilities
*/
class TimeZoneTest extends \Shaarli\TestCase
class TimeZoneTest extends TestCase
{
/**
* @var array of timezones

View file

@ -4,14 +4,15 @@
* Utilities' tests
*/
require_once 'application/Utils.php';
require_once 'application/Languages.php';
namespace Shaarli\Tests;
use DateTime;
use Shaarli\TestCase;
/**
* Unitary tests for Shaarli utilities
*/
class UtilsTest extends \Shaarli\TestCase
class UtilsTest extends TestCase
{
// Log file
protected static $testLogFile = 'tests.log';
@ -55,7 +56,7 @@ protected function setUp(): void
/**
* Returns a list of the elements from the last logged entry
*
* @return list (date, ip address, message)
* @return array (date, ip address, message)
*/
protected function getLastLogEntry()
{

View file

@ -5,6 +5,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -33,7 +34,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -50,7 +51,7 @@ protected function setUp(): void
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('api.secret', 'NapoleonWasALizard');
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');

View file

@ -4,14 +4,14 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceHistory;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
use Slim\Http\Response;
require_once 'tests/utils/ReferenceHistory.php';
class HistoryTest extends \Shaarli\TestCase
class HistoryTest extends TestCase
{
/**
* @var string datastore to test write operations
@ -24,7 +24,7 @@ class HistoryTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceHistory instance.
* @var ReferenceHistory instance.
*/
protected $refHistory = null;
@ -44,7 +44,7 @@ class HistoryTest extends \Shaarli\TestCase
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refHistory = new \ReferenceHistory();
$this->refHistory = new ReferenceHistory();
$this->refHistory->write(self::$testHistory);
$this->container = new Container();
$this->container['conf'] = $this->conf;

View file

@ -8,6 +8,7 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -33,7 +34,7 @@ class InfoTest extends TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -55,7 +56,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$this->pluginManager = new PluginManager($this->conf);
$history = new History('sandbox/history.php');
@ -96,7 +97,7 @@ public function testGetInfo()
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(2, $data['private_counter']);
$this->assertEquals('Shaarli', $data['settings']['title']);
$this->assertEquals('?', $data['settings']['header_link']);
@ -119,7 +120,7 @@ public function testGetInfo()
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(2, $data['private_counter']);
$this->assertEquals($title, $data['settings']['title']);
$this->assertEquals($headerLink, $data['settings']['header_link']);

View file

@ -7,6 +7,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -30,7 +32,7 @@ class DeleteLinkTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -68,9 +70,9 @@ protected function setUp(): void
$this->mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$this->pluginManager = new PluginManager($this->conf);

View file

@ -8,6 +8,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -35,7 +36,7 @@ class GetLinkIdTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -52,7 +53,7 @@ class GetLinkIdTest extends \Shaarli\TestCase
/**
* Number of JSON fields per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;
/**
* Before each test, instantiate a new Api with its config, plugins and bookmarks.
@ -62,7 +63,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');

View file

@ -9,6 +9,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -36,7 +37,7 @@ class GetLinksTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -53,7 +54,7 @@ class GetLinksTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;
/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
@ -63,7 +64,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');
@ -431,7 +432,7 @@ public function testGetLinksSearchTags()
$response = $this->controller->getLinks($request, new Response());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, count($data));
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data));
$this->assertEquals(10, $data[0]['id']);
$this->assertEquals(41, $data[2]['id']);

View file

@ -9,6 +9,8 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -40,7 +42,7 @@ class PostLinkTest extends TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -67,7 +69,7 @@ class PostLinkTest extends TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;
/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
@ -77,9 +79,9 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$pluginManager = new PluginManager($this->conf);

View file

@ -8,6 +8,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -31,7 +33,7 @@ class PutLinkTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -58,7 +60,7 @@ class PutLinkTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;
/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
@ -68,9 +70,9 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$pluginManager = new PluginManager($this->conf);

View file

@ -8,6 +8,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -31,7 +33,7 @@ class DeleteTagTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -69,9 +71,9 @@ protected function setUp(): void
$this->mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$this->pluginManager = new PluginManager($this->conf);

View file

@ -8,6 +8,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -33,7 +34,7 @@ class GetTagNameTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -53,7 +54,7 @@ class GetTagNameTest extends \Shaarli\TestCase
/**
* Number of JSON fields per link.
*/
const NB_FIELDS_TAG = 2;
protected const NB_FIELDS_TAG = 2;
/**
* Before each test, instantiate a new Api with its config, plugins and bookmarks.
@ -63,7 +64,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');

View file

@ -8,6 +8,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -33,7 +34,7 @@ class GetTagsTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -58,7 +59,7 @@ class GetTagsTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_TAG = 2;
protected const NB_FIELDS_TAG = 2;
/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
@ -68,7 +69,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');
$this->pluginManager = new PluginManager($this->conf);

View file

@ -9,6 +9,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
@ -32,7 +34,7 @@ class PutTagTest extends \Shaarli\TestCase
protected $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;
@ -62,7 +64,7 @@ class PutTagTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_TAG = 2;
protected const NB_FIELDS_TAG = 2;
/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
@ -72,9 +74,9 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$this->pluginManager = new PluginManager($this->conf);

View file

@ -3,6 +3,7 @@
namespace Shaarli\Bookmark;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Class BookmarkArrayTest
@ -194,7 +195,7 @@ public function testArrayAccessIterate()
*/
public function testReorder()
{
$refDB = new \ReferenceLinkDB();
$refDB = new ReferenceLinkDB();
$refDB->write('sandbox/datastore.php');

View file

@ -8,7 +8,6 @@
use DateTime;
use malkusch\lock\mutex\NoMutex;
use ReferenceLinkDB;
use ReflectionClass;
use Shaarli;
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
@ -17,6 +16,8 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\FakeBookmarkService;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Unitary tests for LegacyLinkDBTest
@ -95,7 +96,7 @@ protected function setUp(): void
$this->conf = new ConfigManager(self::$testConf);
$this->conf->set('resource.datastore', self::$testDatastore);
$this->conf->set('resource.updates', self::$testUpdates);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$this->history = new History('sandbox/history.php');
$this->pluginManager = new PluginManager($this->conf);
@ -124,12 +125,12 @@ public function testDatabaseMigration()
define('SHAARLI_VERSION', 'dev');
}
$this->refDB = new \ReferenceLinkDB(true);
$this->refDB = new ReferenceLinkDB(true);
$this->refDB->write(self::$testDatastore);
$db = self::getMethod('migrate');
$db->invokeArgs($this->privateLinkDB, []);
$db = new \FakeBookmarkService(
$db = new FakeBookmarkService(
$this->conf,
$this->pluginManager,
$this->history,
@ -204,7 +205,7 @@ public function testAddFull()
$this->assertEquals($updated, $bookmark->getUpdated());
// reload from file
$this->privateLinkDB = new \FakeBookmarkService(
$this->privateLinkDB = new FakeBookmarkService(
$this->conf,
$this->pluginManager,
$this->history,
@ -715,7 +716,7 @@ public function testCheckDBNewLoggedOut()
{
unlink(self::$testDatastore);
$this->assertFileNotExists(self::$testDatastore);
$db = new \FakeBookmarkService($this->conf, $this->pluginManager, $this->history, $this->mutex, false);
$db = new FakeBookmarkService($this->conf, $this->pluginManager, $this->history, $this->mutex, false);
$this->assertFileNotExists(self::$testDatastore);
$this->assertInstanceOf(BookmarkArray::class, $db->getBookmarks());
$this->assertCount(0, $db->getBookmarks());

View file

@ -3,11 +3,12 @@
namespace Shaarli\Bookmark;
use malkusch\lock\mutex\NoMutex;
use ReferenceLinkDB;
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\FakeBookmarkService;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Class BookmarkFilterTest.
@ -46,10 +47,10 @@ public static function setUpBeforeClass(): void
$conf = new ConfigManager('tests/utils/config/configJson');
$conf->set('resource.datastore', self::$testDatastore);
static::$pluginManager = new PluginManager($conf);
self::$refDB = new \ReferenceLinkDB();
self::$refDB = new ReferenceLinkDB();
self::$refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');
self::$bookmarkService = new \FakeBookmarkService($conf, static::$pluginManager, $history, $mutex, true);
self::$bookmarkService = new FakeBookmarkService($conf, static::$pluginManager, $history, $mutex, true);
self::$linkFilter = new BookmarkFilter(self::$bookmarkService->getBookmarks(), $conf, static::$pluginManager);
}

View file

@ -7,6 +7,7 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Class BookmarkInitializerTest
@ -73,7 +74,7 @@ public function setUp(): void
*/
public function testInitializeNotEmptyDataStore(): void
{
$refDB = new \ReferenceLinkDB();
$refDB = new ReferenceLinkDB();
$refDB->write(self::$testDatastore);
$this->bookmarkService = new BookmarkFileService(
$this->conf,

View file

@ -4,8 +4,6 @@
use Shaarli\TestCase;
require_once 'tests/utils/CurlUtils.php';
/**
* Class LinkUtilsTest.
*/
@ -701,7 +699,10 @@ public function testTagsFilterWithSpaceSeparator(): void
static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter(['tag1', 'tag2', 'tag3'], $separator));
static::assertSame(['tag1,', 'tag2@', 'tag3'], tags_filter(['tag1,', 'tag2@', 'tag3'], $separator));
static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter([' tag1 ', 'tag2', 'tag3 '], $separator));
static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter([' tag1 ', ' ', 'tag2', ' ', 'tag3 '], $separator));
static::assertSame(
['tag1', 'tag2', 'tag3'],
tags_filter([' tag1 ', ' ', 'tag2', ' ', 'tag3 '], $separator)
);
static::assertSame(['tag1'], tags_filter([' tag1 '], $separator));
static::assertSame([], tags_filter([' '], $separator));
static::assertSame([], tags_filter([], $separator));
@ -721,7 +722,10 @@ public function testTagsArrayFilterWithSpaceSeparator(): void
['tag1', 'tag2, and other', 'tag3'],
tags_filter(['@@@@ tag1@@@', ' @tag2, and other @', 'tag3@@@@'], $separator)
);
static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter(['@@@tag1@@@', '@', 'tag2', '@@@', 'tag3@@@'], $separator));
static::assertSame(
['tag1', 'tag2', 'tag3'],
tags_filter(['@@@tag1@@@', '@', 'tag2', '@@@', 'tag3@@@'], $separator)
);
static::assertSame(['tag1'], tags_filter(['@@@@tag1@@@@'], $separator));
static::assertSame([], tags_filter(['@@@'], $separator));
static::assertSame([], tags_filter([], $separator));

View file

@ -2,6 +2,8 @@
require_once 'vendor/autoload.php';
use Shaarli\Tests\Utils\ReferenceSessionIdHashes;
$conf = new \Shaarli\Config\ConfigManager('tests/utils/config/configJson');
new \Shaarli\Languages('en', $conf);
@ -13,23 +15,26 @@ function is_iterable($var)
}
}
// TODO: remove this after fixing UT
// raw functions
require_once 'application/config/ConfigPlugin.php';
require_once 'application/bookmark/LinkUtils.php';
require_once 'application/Utils.php';
require_once 'application/http/UrlUtils.php';
require_once 'application/http/HttpUtils.php';
require_once 'application/Utils.php';
require_once 'application/TimeZone.php';
require_once 'tests/utils/CurlUtils.php';
require_once 'tests/utils/RainTPL.php';
// TODO: remove this after fixing UT
require_once 'tests/TestCase.php';
require_once 'tests/container/ShaarliTestContainer.php';
require_once 'tests/front/controller/visitor/FrontControllerMockHelper.php';
require_once 'tests/front/controller/admin/FrontAdminControllerMockHelper.php';
require_once 'tests/updater/DummyUpdater.php';
require_once 'tests/utils/FakeBookmarkService.php';
require_once 'tests/utils/FakeConfigManager.php';
require_once 'tests/utils/ReferenceHistory.php';
require_once 'tests/utils/ReferenceLinkDB.php';
require_once 'tests/utils/ReferenceSessionIdHashes.php';
\ReferenceSessionIdHashes::genAllHashes();
ReferenceSessionIdHashes::genAllHashes();
if (!defined('SHAARLI_MUTEX_FILE')) {
define('SHAARLI_MUTEX_FILE', __FILE__);

View file

@ -4,13 +4,12 @@
use Shaarli\Config\Exception\PluginConfigOrderException;
use Shaarli\Plugin\PluginManager;
require_once 'application/config/ConfigPlugin.php';
use Shaarli\TestCase;
/**
* Unitary tests for Shaarli config related functions
*/
class ConfigPluginTest extends \Shaarli\TestCase
class ConfigPluginTest extends TestCase
{
/**
* Test save_plugin_config with valid data.
@ -54,7 +53,7 @@ public function testSavePluginConfigValid()
*/
public function testSavePluginConfigInvalid()
{
$this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class);
$this->expectException(PluginConfigOrderException::class);
$data = [
'plugin2' => 0,

View file

@ -4,7 +4,6 @@
use DateTime;
use malkusch\lock\mutex\NoMutex;
use ReferenceLinkDB;
use Shaarli\Bookmark\Bookmark;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\LinkDB;
@ -13,6 +12,7 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* FeedBuilderTest class.
@ -52,7 +52,7 @@ public static function setUpBeforeClass(): void
$mutex = new NoMutex();
$conf = new ConfigManager('tests/utils/config/configJson');
$conf->set('resource.datastore', self::$testDatastore);
$refLinkDB = new \ReferenceLinkDB();
$refLinkDB = new ReferenceLinkDB();
$refLinkDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');
$factory = new FormatterFactory($conf, true);
@ -100,7 +100,10 @@ public function testRSSBuildData()
// Test first not pinned link (note link)
$link = $data['links'][array_keys($data['links'])[0]];
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
$this->assertEquals(
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'),
$link['created']
);
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
$this->assertRegExp('/Tue, 10 Mar 2015 11:46:51 \+\d{4}/', $link['pub_iso_date']);
@ -164,7 +167,10 @@ public function testBuildDataFiltered()
$this->assertEquals(1, count($data['links']));
$link = array_shift($data['links']);
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
$this->assertEquals(
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'),
$link['created']
);
}
/**
@ -186,7 +192,10 @@ public function testBuildDataCount()
$this->assertEquals(3, count($data['links']));
$link = $data['links'][array_keys($data['links'])[0]];
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
$this->assertEquals(
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'),
$link['created']
);
}
/**
@ -208,7 +217,10 @@ public function testBuildDataPermalinks()
// First link is a permalink
$link = $data['links'][array_keys($data['links'])[0]];
$this->assertEquals(41, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
$this->assertEquals(
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'),
$link['created']
);
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
$this->assertContainsPolyfill('Direct link', $link['description']);
@ -216,7 +228,10 @@ public function testBuildDataPermalinks()
// Second link is a direct link
$link = $data['links'][array_keys($data['links'])[1]];
$this->assertEquals(8, $link['id']);
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']);
$this->assertEquals(
DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'),
$link['created']
);
$this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']);
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']);
$this->assertContainsPolyfill('Direct link', $link['description']);

View file

@ -16,7 +16,7 @@ class PluginsControllerTest extends TestCase
{
use FrontAdminControllerMockHelper;
const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4'];
protected const PLUGIN_NAMES = ['plugin1', 'plugin2', 'plugin3', 'plugin4'];
/** @var PluginsController */
protected $controller;

View file

@ -15,7 +15,7 @@ class InstallControllerTest extends TestCase
{
use FrontControllerMockHelper;
const MOCK_FILE = '.tmp';
protected const MOCK_FILE = '.tmp';
/** @var InstallController */
protected $controller;

View file

@ -3,9 +3,7 @@
namespace Shaarli\Helper;
use Shaarli\Config\ConfigManager;
use Shaarli\FakeApplicationUtils;
require_once 'tests/utils/FakeApplicationUtils.php';
use Shaarli\Tests\Utils\FakeApplicationUtils;
/**
* Unitary tests for Shaarli utilities

View file

@ -4,6 +4,7 @@
namespace Shaarli\Helper;
use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Shaarli\Bookmark\Bookmark;
@ -209,31 +210,31 @@ public function getRequestedTypes(): array
public function getRequestedDateTimes(): array
{
return [
[DailyPageHelper::DAY, '20201013', null, new \DateTime('2020-10-13')],
[DailyPageHelper::DAY, '20201013', null, new DateTime('2020-10-13')],
[
DailyPageHelper::DAY,
'',
(new Bookmark())->setCreated($date = new \DateTime('2020-10-13 12:05:31')),
(new Bookmark())->setCreated($date = new DateTime('2020-10-13 12:05:31')),
$date,
],
[DailyPageHelper::DAY, '', null, new \DateTime()],
[DailyPageHelper::WEEK, '202030', null, new \DateTime('2020-07-20')],
[DailyPageHelper::DAY, '', null, new DateTime()],
[DailyPageHelper::WEEK, '202030', null, new DateTime('2020-07-20')],
[
DailyPageHelper::WEEK,
'',
(new Bookmark())->setCreated($date = new \DateTime('2020-10-13 12:05:31')),
new \DateTime('2020-10-13'),
(new Bookmark())->setCreated($date = new DateTime('2020-10-13 12:05:31')),
new DateTime('2020-10-13'),
],
[DailyPageHelper::WEEK, '', null, new \DateTime(), 'Ym'],
[DailyPageHelper::MONTH, '202008', null, new \DateTime('2020-08-01'), 'Ym'],
[DailyPageHelper::WEEK, '', null, new DateTime(), 'Ym'],
[DailyPageHelper::MONTH, '202008', null, new DateTime('2020-08-01'), 'Ym'],
[
DailyPageHelper::MONTH,
'',
(new Bookmark())->setCreated($date = new \DateTime('2020-10-13 12:05:31')),
new \DateTime('2020-10-13'),
(new Bookmark())->setCreated($date = new DateTime('2020-10-13 12:05:31')),
new DateTime('2020-10-13'),
'Ym'
],
[DailyPageHelper::MONTH, '', null, new \DateTime(), 'Ym'],
[DailyPageHelper::MONTH, '', null, new DateTime(), 'Ym'],
];
}
@ -255,9 +256,9 @@ public function getFormatsByType(): array
public function getStartDatesByType(): array
{
return [
[DailyPageHelper::DAY, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-09 00:00:00')],
[DailyPageHelper::WEEK, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-05 00:00:00')],
[DailyPageHelper::MONTH, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-01 00:00:00')],
[DailyPageHelper::DAY, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-09 00:00:00')],
[DailyPageHelper::WEEK, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-05 00:00:00')],
[DailyPageHelper::MONTH, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-01 00:00:00')],
];
}
@ -267,9 +268,9 @@ public function getStartDatesByType(): array
public function getEndDatesByType(): array
{
return [
[DailyPageHelper::DAY, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-09 23:59:59')],
[DailyPageHelper::WEEK, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-11 23:59:59')],
[DailyPageHelper::MONTH, new DateTimeImmutable('2020-10-09 04:05:06'), new \DateTime('2020-10-31 23:59:59')],
[DailyPageHelper::DAY, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-09 23:59:59')],
[DailyPageHelper::WEEK, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-11 23:59:59')],
[DailyPageHelper::MONTH, new DateTimeImmutable('2020-10-09 04:05:06'), new DateTime('2020-10-31 23:59:59')],
];
}
@ -322,20 +323,20 @@ public function getCacheDatePeriodByType(): array
[
DailyPageHelper::DAY,
new DateTimeImmutable('2020-10-09 04:05:06'),
new \DateTime('2020-10-09 00:00:00'),
new \DateTime('2020-10-09 23:59:59'),
new DateTime('2020-10-09 00:00:00'),
new DateTime('2020-10-09 23:59:59'),
],
[
DailyPageHelper::WEEK,
new DateTimeImmutable('2020-10-09 04:05:06'),
new \DateTime('2020-10-05 00:00:00'),
new \DateTime('2020-10-11 23:59:59'),
new DateTime('2020-10-05 00:00:00'),
new DateTime('2020-10-11 23:59:59'),
],
[
DailyPageHelper::MONTH,
new DateTimeImmutable('2020-10-09 04:05:06'),
new \DateTime('2020-10-01 00:00:00'),
new \DateTime('2020-10-31 23:59:59'),
new DateTime('2020-10-01 00:00:00'),
new DateTime('2020-10-31 23:59:59'),
],
];
}

View file

@ -6,8 +6,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for client_ip_id()
*/

View file

@ -6,8 +6,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for get_http_response()
*/

View file

@ -2,8 +2,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for getIpAddressFromProxy()
*/

View file

@ -8,8 +8,6 @@
use Shaarli\TestCase;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for index_url()
*/

View file

@ -2,8 +2,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Class IsHttpsTest
*

View file

@ -6,8 +6,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for page_url()
*/

View file

@ -6,8 +6,6 @@
namespace Shaarli\Http;
require_once 'application/http/HttpUtils.php';
/**
* Unitary tests for server_url()
*/

View file

@ -6,8 +6,6 @@
namespace Shaarli\Http;
require_once 'application/http/UrlUtils.php';
class CleanupUrlTest extends \Shaarli\TestCase
{
/**

View file

@ -6,9 +6,9 @@
namespace Shaarli\Http;
require_once 'application/http/UrlUtils.php';
use Shaarli\TestCase;
class GetUrlSchemeTest extends \Shaarli\TestCase
class GetUrlSchemeTest extends TestCase
{
/**
* Get empty scheme string for empty UrlUtils

View file

@ -6,12 +6,12 @@
namespace Shaarli\Http;
require_once 'application/http/UrlUtils.php';
use Shaarli\TestCase;
/**
* Unitary tests for unparse_url()
*/
class UnparseUrlTest extends \Shaarli\TestCase
class UnparseUrlTest extends TestCase
{
/**
* Thanks for building nothing

View file

@ -2,14 +2,14 @@
namespace Shaarli\Http;
require_once 'application/http/UrlUtils.php';
use Shaarli\TestCase;
/**
* Class WhitelistProtocolsTest
*
* Test whitelist_protocols() function of UrlUtils.
*/
class WhitelistProtocolsTest extends \Shaarli\TestCase
class WhitelistProtocolsTest extends TestCase
{
/**
* Test whitelist_protocols() on a note (relative URL).

View file

@ -1,7 +1,8 @@
<?php
require_once 'tests/UtilsTest.php';
namespace Shaarli\Tests;
use DateTime;
class UtilsDeTest extends UtilsTest
{

View file

@ -1,7 +1,8 @@
<?php
require_once 'tests/UtilsTest.php';
namespace Shaarli\Tests;
use DateTime;
class UtilsEnTest extends UtilsTest
{

View file

@ -1,8 +1,10 @@
<?php
namespace Shaarli;
namespace Shaarli\Tests;
use Shaarli\Config\ConfigManager;
use Shaarli\Languages;
use Shaarli\TestCase;
/**
* Class LanguagesFrTest
@ -11,7 +13,7 @@
*
* @package Shaarli
*/
class LanguagesFrTest extends \Shaarli\TestCase
class LanguagesFrTest extends TestCase
{
/**
* @var string Config file path (without extension).

View file

@ -1,7 +1,8 @@
<?php
require_once 'tests/UtilsTest.php';
namespace Shaarli\Tests;
use DateTime;
class UtilsFrTest extends UtilsTest
{

View file

@ -7,14 +7,10 @@
namespace Shaarli\Legacy;
use DateTime;
use ReferenceLinkDB;
use ReflectionClass;
use Shaarli;
use Shaarli\Bookmark\Bookmark;
require_once 'application/Utils.php';
require_once 'tests/utils/ReferenceLinkDB.php';
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Unitary tests for LegacyLinkDBTest

View file

@ -2,10 +2,9 @@
namespace Shaarli\Bookmark;
use Exception;
use ReferenceLinkDB;
use Shaarli\Legacy\LegacyLinkDB;
use Shaarli\Legacy\LegacyLinkFilter;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Class LegacyLinkFilterTest.

View file

@ -10,18 +10,16 @@
use Shaarli\Config\ConfigPhp;
use Shaarli\Legacy\LegacyLinkDB;
use Shaarli\Legacy\LegacyUpdater;
use Shaarli\TestCase;
use Shaarli\Tests\updater\DummyUpdater;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Shaarli\Thumbnailer;
require_once 'application/updater/UpdaterUtils.php';
require_once 'tests/updater/DummyUpdater.php';
require_once 'tests/utils/ReferenceLinkDB.php';
require_once 'inc/rain.tpl.class.php';
/**
* Class UpdaterTest.
* Runs unit tests against the updater class.
*/
class LegacyUpdaterTest extends \Shaarli\TestCase
class LegacyUpdaterTest extends TestCase
{
/**
* @var string Path to test datastore.
@ -226,7 +224,7 @@ public function testMergeDeprecatedConfigNoFile()
*/
public function testRenameDashTags()
{
$refDB = new \ReferenceLinkDB(true);
$refDB = new ReferenceLinkDB(true);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@ -369,7 +367,7 @@ public function testDatastoreIds()
'private' => true,
],
];
$refDB = new \ReferenceLinkDB(true);
$refDB = new ReferenceLinkDB(true);
$refDB->setLinks($links);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@ -438,7 +436,7 @@ public function testDatastoreIds()
*/
public function testDatastoreIdsNothingToDo()
{
$refDB = new \ReferenceLinkDB(true);
$refDB = new ReferenceLinkDB(true);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@ -782,7 +780,7 @@ public function testUpdateStickyValid()
1 => ['id' => 1] + $blank,
2 => ['id' => 2] + $blank,
];
$refDB = new \ReferenceLinkDB(true);
$refDB = new ReferenceLinkDB(true);
$refDB->setLinks($links);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@ -813,7 +811,7 @@ public function testUpdateStickyNothingToDo()
1 => ['id' => 1, 'sticky' => true] + $blank,
2 => ['id' => 2] + $blank,
];
$refDB = new \ReferenceLinkDB(true);
$refDB = new ReferenceLinkDB(true);
$refDB->setLinks($links);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);

View file

@ -10,8 +10,7 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
require_once 'tests/utils/ReferenceLinkDB.php';
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Netscape bookmark export
@ -29,7 +28,7 @@ class BookmarkExportTest extends TestCase
protected static $conf;
/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected static $refDb = null;
@ -64,7 +63,7 @@ public static function setUpBeforeClass(): void
$mutex = new NoMutex();
static::$conf = new ConfigManager('tests/utils/config/configJson');
static::$conf->set('resource.datastore', static::$testDatastore);
static::$refDb = new \ReferenceLinkDB();
static::$refDb = new ReferenceLinkDB();
static::$refDb->write(static::$testDatastore);
static::$history = new History('sandbox/history.php');
static::$pluginManager = new PluginManager(static::$conf);

View file

@ -2,10 +2,6 @@
namespace Shaarli\Plugin\Archiveorg;
/**
* PluginArchiveorgTest.php
*/
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;

View file

@ -117,8 +117,14 @@ public function testIssoMultipleLinks(): void
$processed = hook_isso_render_linklist($data, $conf);
// link_plugin should be added for the icon
$this->assertContainsPolyfill('<a href="/shaare/' . $short1 . '#isso-thread">', $processed['links'][0]['link_plugin'][0]);
$this->assertContainsPolyfill('<a href="/shaare/' . $short2 . '#isso-thread">', $processed['links'][1]['link_plugin'][0]);
$this->assertContainsPolyfill(
'<a href="/shaare/' . $short1 . '#isso-thread">',
$processed['links'][0]['link_plugin'][0]
);
$this->assertContainsPolyfill(
'<a href="/shaare/' . $short2 . '#isso-thread">',
$processed['links'][1]['link_plugin'][0]
);
}
/**
@ -147,7 +153,10 @@ public function testIssoNotDisplayedWhenSearch(): void
$processed = hook_isso_render_linklist($data, $conf);
// link_plugin should be added for the icon
$this->assertContainsPolyfill('<a href="/shaare/' . $short1 . '#isso-thread">', $processed['links'][0]['link_plugin'][0]);
$this->assertContainsPolyfill(
'<a href="/shaare/' . $short1 . '#isso-thread">',
$processed['links'][0]['link_plugin'][0]
);
}
/**

View file

@ -2,10 +2,6 @@
namespace Shaarli\Plugin\Playvideos;
/**
* PluginPlayvideosTest.php
*/
use Shaarli\Plugin\PluginManager;
use Shaarli\Render\TemplatePage;

View file

@ -2,10 +2,6 @@
namespace Shaarli\Plugin\Qrcode;
/**
* PluginQrcodeTest.php
*/
use Shaarli\Plugin\PluginManager;
use Shaarli\Render\TemplatePage;

View file

@ -4,6 +4,7 @@
use Shaarli\FakeConfigManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceSessionIdHashes;
/**
* Test coverage for SessionManager
@ -27,7 +28,7 @@ class SessionManagerTest extends TestCase
*/
public static function setUpBeforeClass(): void
{
self::$sidHashes = \ReferenceSessionIdHashes::getHashes();
self::$sidHashes = ReferenceSessionIdHashes::getHashes();
}
/**

View file

@ -1,6 +1,6 @@
<?php
namespace Shaarli\Updater;
namespace Shaarli\Tests\updater;
use Exception;
use ReflectionClass;
@ -8,6 +8,7 @@
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager;
use Shaarli\Updater\Updater;
/**
* Class DummyUpdater.

View file

@ -10,6 +10,8 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\updater\DummyUpdater;
use Shaarli\Tests\Utils\ReferenceLinkDB;
/**
* Class UpdaterTest.
@ -35,7 +37,7 @@ class UpdaterTest extends TestCase
/** @var BookmarkServiceInterface */
protected $bookmarkService;
/** @var \ReferenceLinkDB */
/** @var ReferenceLinkDB */
protected $refDB;
/** @var Updater */
@ -47,7 +49,7 @@ class UpdaterTest extends TestCase
protected function setUp(): void
{
$mutex = new NoMutex();
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
copy('tests/utils/config/configJson.json.php', self::$configFile . '.json.php');

View file

@ -1,6 +1,6 @@
<?php
namespace Shaarli;
namespace Shaarli\Tests\Utils;
use Shaarli\Helper\ApplicationUtils;

View file

@ -1,12 +1,8 @@
<?php
use Shaarli\Bookmark\BookmarkArray;
use Shaarli\Bookmark\BookmarkFilter;
use Shaarli\Bookmark\BookmarkIO;
namespace Shaarli\Tests\Utils;
use Shaarli\Bookmark\BookmarkFileService;
use Shaarli\Bookmark\Exception\EmptyDataStoreException;
use Shaarli\Config\ConfigManager;
use Shaarli\History;
class FakeBookmarkService extends BookmarkFileService
{

6
tests/utils/RainTPL.php Normal file
View file

@ -0,0 +1,6 @@
<?php
class RainTPL
{
public static $tpl_dir = '';
}

View file

@ -1,5 +1,8 @@
<?php
namespace Shaarli\Tests\Utils;
use DateTime;
use Shaarli\Helper\FileUtils;
use Shaarli\History;

View file

@ -1,5 +1,8 @@
<?php
namespace Shaarli\Tests\Utils;
use DateTime;
use Shaarli\Bookmark\Bookmark;
use Shaarli\Bookmark\BookmarkArray;
@ -10,11 +13,11 @@ class ReferenceLinkDB
{
public static $NB_LINKS_TOTAL = 11;
private $bookmarks = [];
private $_publicCount = 0;
private $_privateCount = 0;
protected $bookmarks = [];
protected $publicCount = 0;
protected $privateCount = 0;
private $isLegacy;
protected $isLegacy;
/**
* Populates the test DB with reference data
@ -184,10 +187,10 @@ protected function addLink(
}
if ($private) {
$this->_privateCount++;
$this->privateCount++;
return;
}
$this->_publicCount++;
$this->publicCount++;
}
/**
@ -233,7 +236,7 @@ public function reorder($order = 'DESC')
*/
public function countLinks()
{
return $this->_publicCount + $this->_privateCount;
return $this->publicCount + $this->privateCount;
}
/**
@ -241,7 +244,7 @@ public function countLinks()
*/
public function countPublicLinks()
{
return $this->_publicCount;
return $this->publicCount;
}
/**
@ -249,7 +252,7 @@ public function countPublicLinks()
*/
public function countPrivateLinks()
{
return $this->_privateCount;
return $this->privateCount;
}
/**

View file

@ -1,5 +1,7 @@
<?php
namespace Shaarli\Tests\Utils;
/**
* Testing the untestable - Session ID generation
*/