'.
- '<h2>Content</h2><p>`Here is some content</p>'.
+ '
',
$link['description']
);
@@ -112,21 +112,21 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
*/
public function testFormatExtrraDescription(): void
{
- $description = 'This a
'. PHP_EOL;
- $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. PHP_EOL;
- $description .= 'Also, there is an #hashtag added'. PHP_EOL;
- $description .= ' A N D KEEP SPACES ! '. PHP_EOL;
- $description .= '# Header {.class}'. PHP_EOL;
+ $description = 'This a
' . PHP_EOL;
+ $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text' . PHP_EOL;
+ $description .= 'Also, there is an #hashtag added' . PHP_EOL;
+ $description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
+ $description .= '# Header {.class}' . PHP_EOL;
$bookmark = new Bookmark();
$bookmark->setDescription($description);
$link = $this->formatter->format($bookmark);
$description = '
';
@@ -148,7 +148,7 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
$description = '
';
$link = $this->formatter->format($bookmark);
diff --git a/tests/formatter/BookmarkMarkdownFormatterTest.php b/tests/formatter/BookmarkMarkdownFormatterTest.php
index 32f7b444..92668510 100644
--- a/tests/formatter/BookmarkMarkdownFormatterTest.php
+++ b/tests/formatter/BookmarkMarkdownFormatterTest.php
@@ -27,7 +27,7 @@ class BookmarkMarkdownFormatterTest extends TestCase
*/
protected function setUp(): void
{
- copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
+ copy('tests/utils/config/configJson.json.php', self::$testConf . '.json.php');
$this->conf = new ConfigManager(self::$testConf);
$this->formatter = new BookmarkMarkdownFormatter($this->conf, true);
}
@@ -60,8 +60,8 @@ class BookmarkMarkdownFormatterTest extends TestCase
);
$this->assertEquals('This is a <strong>bookmark</strong>', $link['title']);
$this->assertEquals(
- '
'.
- '<h2>Content</h2><p>`Here is some content</p>'.
+ '
' .
+ '<h2>Content</h2><p>`Here is some content</p>' .
'
',
$link['description']
);
@@ -112,20 +112,20 @@ class BookmarkMarkdownFormatterTest extends TestCase
*/
public function testFormatDescription()
{
- $description = 'This a
description'. PHP_EOL;
- $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. PHP_EOL;
- $description .= 'Also, there is an #hashtag added'. PHP_EOL;
- $description .= ' A N D KEEP SPACES ! '. PHP_EOL;
+ $description = 'This a
description' . PHP_EOL;
+ $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text' . PHP_EOL;
+ $description .= 'Also, there is an #hashtag added' . PHP_EOL;
+ $description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
$bookmark = new Bookmark();
$bookmark->setDescription($description);
$link = $this->formatter->format($bookmark);
$description = '
';
- $description .= 'This a <strong>description</strong>
'. PHP_EOL;
+ $description .= 'This a <strong>description</strong>
' . PHP_EOL;
$url = 'https://sub.domain.tld?query=here&for=real#hash';
- $description .= 'text '. $url .' more text
'. PHP_EOL;
- $description .= 'Also, there is an #hashtag added
'. PHP_EOL;
+ $description .= 'text ' . $url . ' more text
' . PHP_EOL;
+ $description .= 'Also, there is an #hashtag added
' . PHP_EOL;
$description .= 'A N D KEEP SPACES ! ';
$description .= '
';
@@ -137,11 +137,11 @@ class BookmarkMarkdownFormatterTest extends TestCase
*/
public function testFormatDescriptionWithSearchHighlight()
{
- $description = 'This a
description'. PHP_EOL;
- $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. PHP_EOL;
- $description .= 'Also, there is an #hashtag added'. PHP_EOL;
- $description .= ' A N D KEEP SPACES ! '. PHP_EOL;
- $description .= 'And [yet another link](https://other.domain.tld)'. PHP_EOL;
+ $description = 'This a
description' . PHP_EOL;
+ $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text' . PHP_EOL;
+ $description .= 'Also, there is an #hashtag added' . PHP_EOL;
+ $description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
+ $description .= 'And [yet another link](https://other.domain.tld)' . PHP_EOL;
$bookmark = new Bookmark();
$bookmark->setDescription($description);
@@ -164,9 +164,9 @@ class BookmarkMarkdownFormatterTest extends TestCase
$url = 'https://sub.domain.tld?query=here&for=real#hash';
$highlighted = 'https://
sub.domain.tld';
$highlighted .= '?query=here&for=real#
hash';
- $description .= 'text
'. $highlighted .' more text
'. PHP_EOL;
+ $description .= 'text
' . $highlighted . ' more text
' . PHP_EOL;
$description .= 'Also, there is an
#hasht' .
- 'ag added
'. PHP_EOL;
+ 'ag added
' . PHP_EOL;
$description .= 'A N D KEEP SPACES !
' . PHP_EOL;
$description .= 'And
' .
'yet another link';
@@ -189,7 +189,7 @@ class BookmarkMarkdownFormatterTest extends TestCase
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
$description = '
';
- $description .= 'Text #hashtag more text';
+ $description .= 'Text #hashtag more text';
$description .= '
';
$link = $this->formatter->format($bookmark);
diff --git a/tests/formatter/BookmarkRawFormatterTest.php b/tests/formatter/BookmarkRawFormatterTest.php
index c76bb7b9..90c9fcf0 100644
--- a/tests/formatter/BookmarkRawFormatterTest.php
+++ b/tests/formatter/BookmarkRawFormatterTest.php
@@ -27,7 +27,7 @@ class BookmarkRawFormatterTest extends TestCase
*/
protected function setUp(): void
{
- copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
+ copy('tests/utils/config/configJson.json.php', self::$testConf . '.json.php');
$this->conf = new ConfigManager(self::$testConf);
$this->formatter = new BookmarkRawFormatter($this->conf, true);
}
diff --git a/tests/formatter/FormatterFactoryTest.php b/tests/formatter/FormatterFactoryTest.php
index ae476cb5..c6b493eb 100644
--- a/tests/formatter/FormatterFactoryTest.php
+++ b/tests/formatter/FormatterFactoryTest.php
@@ -26,7 +26,7 @@ class FormatterFactoryTest extends TestCase
*/
protected function setUp(): void
{
- copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
+ copy('tests/utils/config/configJson.json.php', self::$testConf . '.json.php');
$this->conf = new ConfigManager(self::$testConf);
$this->factory = new FormatterFactory($this->conf, true);
}
diff --git a/tests/front/ShaarliAdminMiddlewareTest.php b/tests/front/ShaarliAdminMiddlewareTest.php
index 44025f11..4d072612 100644
--- a/tests/front/ShaarliAdminMiddlewareTest.php
+++ b/tests/front/ShaarliAdminMiddlewareTest.php
@@ -63,7 +63,8 @@ class ShaarliAdminMiddlewareTest extends TestCase
$response = new Response();
/** @var Response $result */
- $result = $this->middleware->__invoke($request, $response, function () {});
+ $result = $this->middleware->__invoke($request, $response, function () {
+ });
static::assertSame(302, $result->getStatusCode());
static::assertSame(
diff --git a/tests/front/ShaarliMiddlewareTest.php b/tests/front/ShaarliMiddlewareTest.php
index 655c5bba..2fc1e69b 100644
--- a/tests/front/ShaarliMiddlewareTest.php
+++ b/tests/front/ShaarliMiddlewareTest.php
@@ -91,7 +91,7 @@ class ShaarliMiddlewareTest extends TestCase
$controller = function (): void {
$exception = new LoginBannedException();
- throw new $exception;
+ throw new $exception();
};
$pageBuilder = $this->createMock(PageBuilder::class);
@@ -148,7 +148,8 @@ class ShaarliMiddlewareTest extends TestCase
return $uri;
});
- $dummyException = new class() extends \Exception {};
+ $dummyException = new class () extends \Exception {
+ };
$response = new Response();
$controller = function () use ($dummyException): void {
diff --git a/tests/front/controller/admin/ConfigureControllerTest.php b/tests/front/controller/admin/ConfigureControllerTest.php
index 13644df9..3a7cfeac 100644
--- a/tests/front/controller/admin/ConfigureControllerTest.php
+++ b/tests/front/controller/admin/ConfigureControllerTest.php
@@ -122,8 +122,7 @@ class ConfigureControllerTest extends TestCase
}
return $parameters[$key];
- }
- );
+ });
$response = new Response();
@@ -137,8 +136,7 @@ class ConfigureControllerTest extends TestCase
}
static::assertSame($parametersConfigMapping[$key], $value);
- }
- );
+ });
$result = $this->controller->save($request, $response);
static::assertSame(302, $result->getStatusCode());
diff --git a/tests/front/controller/admin/ExportControllerTest.php b/tests/front/controller/admin/ExportControllerTest.php
index 0e6f2762..a8401c1f 100644
--- a/tests/front/controller/admin/ExportControllerTest.php
+++ b/tests/front/controller/admin/ExportControllerTest.php
@@ -80,7 +80,10 @@ class ExportControllerTest extends TestCase
string $selection,
bool $prependNoteUrl,
string $indexUrl
- ) use ($parameters, $bookmarks): array {
+ ) use (
+ $parameters,
+ $bookmarks
+ ): array {
static::assertInstanceOf(BookmarkRawFormatter::class, $formatter);
static::assertSame($parameters['selection'], $selection);
static::assertTrue($prependNoteUrl);
diff --git a/tests/front/controller/admin/ImportControllerTest.php b/tests/front/controller/admin/ImportControllerTest.php
index c266caa5..50513115 100644
--- a/tests/front/controller/admin/ImportControllerTest.php
+++ b/tests/front/controller/admin/ImportControllerTest.php
@@ -74,7 +74,10 @@ class ImportControllerTest extends TestCase
function (
array $post,
UploadedFileInterface $file
- ) use ($parameters, $requestFile): string {
+ ) use (
+ $parameters,
+ $requestFile
+ ): string {
static::assertSame($parameters, $post);
static::assertSame($requestFile, $file);
diff --git a/tests/front/controller/admin/PasswordControllerTest.php b/tests/front/controller/admin/PasswordControllerTest.php
index 58f47b49..e73b3711 100644
--- a/tests/front/controller/admin/PasswordControllerTest.php
+++ b/tests/front/controller/admin/PasswordControllerTest.php
@@ -52,12 +52,12 @@ class PasswordControllerTest extends TestCase
{
$request = $this->createMock(Request::class);
$request->method('getParam')->willReturnCallback(function (string $key): string {
- if ('oldpassword' === $key) {
- return 'old';
- }
- if ('setpassword' === $key) {
- return 'new';
- }
+ if ('oldpassword' === $key) {
+ return 'old';
+ }
+ if ('setpassword' === $key) {
+ return 'new';
+ }
return $key;
});
diff --git a/tests/front/controller/admin/PluginsControllerTest.php b/tests/front/controller/admin/PluginsControllerTest.php
index 974d614d..fbec3197 100644
--- a/tests/front/controller/admin/PluginsControllerTest.php
+++ b/tests/front/controller/admin/PluginsControllerTest.php
@@ -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;
@@ -29,13 +29,17 @@ class PluginsControllerTest extends TestCase
mkdir($path = __DIR__ . '/folder');
PluginManager::$PLUGINS_PATH = $path;
- array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, static::PLUGIN_NAMES);
+ array_map(function (string $plugin) use ($path) {
+ touch($path . '/' . $plugin);
+ }, static::PLUGIN_NAMES);
}
public function tearDown(): void
{
$path = __DIR__ . '/folder';
- array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, static::PLUGIN_NAMES);
+ array_map(function (string $plugin) use ($path) {
+ unlink($path . '/' . $plugin);
+ }, static::PLUGIN_NAMES);
rmdir($path);
}
diff --git a/tests/front/controller/admin/ShaarePublishControllerTest/SaveBookmarkTest.php b/tests/front/controller/admin/ShaarePublishControllerTest/SaveBookmarkTest.php
index b6a861bc..91c377e8 100644
--- a/tests/front/controller/admin/ShaarePublishControllerTest/SaveBookmarkTest.php
+++ b/tests/front/controller/admin/ShaarePublishControllerTest/SaveBookmarkTest.php
@@ -365,5 +365,4 @@ class SaveBookmarkTest extends TestCase
$this->controller->save($request, $response);
}
-
}
diff --git a/tests/front/controller/admin/ShaarliAdminControllerTest.php b/tests/front/controller/admin/ShaarliAdminControllerTest.php
index 486d5d2d..95ac76f1 100644
--- a/tests/front/controller/admin/ShaarliAdminControllerTest.php
+++ b/tests/front/controller/admin/ShaarliAdminControllerTest.php
@@ -26,7 +26,7 @@ class ShaarliAdminControllerTest extends TestCase
{
$this->createContainer();
- $this->controller = new class($this->container) extends ShaarliAdminController
+ $this->controller = new class ($this->container) extends ShaarliAdminController
{
public function checkToken(Request $request): bool
{
diff --git a/tests/front/controller/visitor/BookmarkListControllerTest.php b/tests/front/controller/visitor/BookmarkListControllerTest.php
index 0fbab9d4..cd2740cd 100644
--- a/tests/front/controller/visitor/BookmarkListControllerTest.php
+++ b/tests/front/controller/visitor/BookmarkListControllerTest.php
@@ -54,8 +54,7 @@ class BookmarkListControllerTest extends TestCase
(new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'),
(new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'),
(new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
- ], 0, 2)
- );
+ ], 0, 2));
$this->container->sessionManager
->method('getSessionParameter')
diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php
index 821ba321..b6574b6c 100644
--- a/tests/front/controller/visitor/DailyControllerTest.php
+++ b/tests/front/controller/visitor/DailyControllerTest.php
@@ -102,7 +102,7 @@ class DailyControllerTest extends TestCase
static::assertSame(200, $result->getStatusCode());
static::assertSame('daily', (string) $result->getBody());
static::assertSame(
- 'Daily - '. format_date($currentDay, false, true) .' - Shaarli',
+ 'Daily - ' . format_date($currentDay, false, true) . ' - Shaarli',
$assignedVariables['pagetitle']
);
static::assertEquals($currentDay, $assignedVariables['dayDate']);
@@ -225,7 +225,7 @@ class DailyControllerTest extends TestCase
static::assertSame(200, $result->getStatusCode());
static::assertSame('daily', (string) $result->getBody());
static::assertSame(
- 'Daily - '. format_date($currentDay, false, true) .' - Shaarli',
+ 'Daily - ' . format_date($currentDay, false, true) . ' - Shaarli',
$assignedVariables['pagetitle']
);
static::assertCount(1, $assignedVariables['linksToDisplay']);
@@ -285,7 +285,9 @@ class DailyControllerTest extends TestCase
static::assertCount(7, $assignedVariables['linksToDisplay']);
$columnIds = function (array $column): array {
- return array_map(function (array $item): int { return $item['id']; }, $column);
+ return array_map(function (array $item): int {
+ return $item['id'];
+ }, $column);
};
static::assertSame([1, 4, 6], $columnIds($assignedVariables['cols'][0]));
@@ -366,8 +368,7 @@ class DailyControllerTest extends TestCase
$cachedPage->expects(static::once())->method('cache')->with('dailyrss');
return $cachedPage;
- }
- );
+ });
// Save RainTPL assigned variables
$assignedVariables = [];
@@ -390,7 +391,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame(format_date($date, false), $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?day='. $dates[0]->format('Ymd'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?day=' . $dates[0]->format('Ymd'), $day['absolute_url']);
static::assertCount(1, $day['links']);
static::assertSame(1, $day['links'][0]['id']);
static::assertSame('http://domain.tld/1', $day['links'][0]['url']);
@@ -402,7 +403,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame(format_date($date, false), $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?day='. $dates[1]->format('Ymd'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?day=' . $dates[1]->format('Ymd'), $day['absolute_url']);
static::assertCount(2, $day['links']);
static::assertSame(2, $day['links'][0]['id']);
@@ -418,7 +419,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame(format_date($date, false), $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?day='. $dates[2]->format('Ymd'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?day=' . $dates[2]->format('Ymd'), $day['absolute_url']);
static::assertCount(1, $day['links']);
static::assertSame(4, $day['links'][0]['id']);
static::assertSame('http://domain.tld/4', $day['links'][0]['url']);
@@ -647,7 +648,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame('Week 21 (May 18, 2020)', $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?week='. $dates[0]->format('YW'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?week=' . $dates[0]->format('YW'), $day['absolute_url']);
static::assertCount(1, $day['links']);
$day = $assignedVariables['days'][$dates[1]->format('YW')];
@@ -656,7 +657,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame('Week 20 (May 11, 2020)', $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?week='. $dates[1]->format('YW'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?week=' . $dates[1]->format('YW'), $day['absolute_url']);
static::assertCount(2, $day['links']);
}
@@ -710,7 +711,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame('May, 2020', $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?month='. $dates[0]->format('Ym'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?month=' . $dates[0]->format('Ym'), $day['absolute_url']);
static::assertCount(1, $day['links']);
$day = $assignedVariables['days'][$dates[1]->format('Ym')];
@@ -719,7 +720,7 @@ class DailyControllerTest extends TestCase
static::assertEquals($date, $day['date']);
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
static::assertSame('April, 2020', $day['date_human']);
- static::assertSame('http://shaarli/subfolder/daily?month='. $dates[1]->format('Ym'), $day['absolute_url']);
+ static::assertSame('http://shaarli/subfolder/daily?month=' . $dates[1]->format('Ym'), $day['absolute_url']);
static::assertCount(2, $day['links']);
}
}
diff --git a/tests/front/controller/visitor/ErrorControllerTest.php b/tests/front/controller/visitor/ErrorControllerTest.php
index e18a6fa2..e0dc8db8 100644
--- a/tests/front/controller/visitor/ErrorControllerTest.php
+++ b/tests/front/controller/visitor/ErrorControllerTest.php
@@ -41,7 +41,8 @@ class ErrorControllerTest extends TestCase
$result = ($this->controller)(
$request,
$response,
- new class($message, $errorCode) extends ShaarliFrontException {}
+ new class ($message, $errorCode) extends ShaarliFrontException {
+ }
);
static::assertSame($errorCode, $result->getStatusCode());
diff --git a/tests/front/controller/visitor/FrontControllerMockHelper.php b/tests/front/controller/visitor/FrontControllerMockHelper.php
index 02229f68..b0b00e95 100644
--- a/tests/front/controller/visitor/FrontControllerMockHelper.php
+++ b/tests/front/controller/visitor/FrontControllerMockHelper.php
@@ -118,5 +118,5 @@ trait FrontControllerMockHelper
/**
* Force to be used in PHPUnit context.
*/
- protected abstract function isInTestsContext(): bool;
+ abstract protected function isInTestsContext(): bool;
}
diff --git a/tests/front/controller/visitor/InstallControllerTest.php b/tests/front/controller/visitor/InstallControllerTest.php
index 2105ed77..ea29592c 100644
--- a/tests/front/controller/visitor/InstallControllerTest.php
+++ b/tests/front/controller/visitor/InstallControllerTest.php
@@ -15,7 +15,7 @@ class InstallControllerTest extends TestCase
{
use FrontControllerMockHelper;
- const MOCK_FILE = '.tmp';
+ protected const MOCK_FILE = '.tmp';
/** @var InstallController */
protected $controller;
diff --git a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php
index 7676f14d..61886f7d 100644
--- a/tests/front/controller/visitor/ShaarliVisitorControllerTest.php
+++ b/tests/front/controller/visitor/ShaarliVisitorControllerTest.php
@@ -32,7 +32,7 @@ class ShaarliVisitorControllerTest extends TestCase
{
$this->createContainer();
- $this->controller = new class($this->container) extends ShaarliVisitorController
+ $this->controller = new class ($this->container) extends ShaarliVisitorController
{
public function assignView(string $key, $value): ShaarliVisitorController
{
diff --git a/tests/front/controller/visitor/TagCloudControllerTest.php b/tests/front/controller/visitor/TagCloudControllerTest.php
index 4915573d..f2509461 100644
--- a/tests/front/controller/visitor/TagCloudControllerTest.php
+++ b/tests/front/controller/visitor/TagCloudControllerTest.php
@@ -130,12 +130,12 @@ class TagCloudControllerTest extends TestCase
->method('executeHooks')
->withConsecutive(['render_tagcloud'])
->willReturnCallback(function (string $hook, array $data, array $param): array {
- if ('render_tagcloud' === $hook) {
- static::assertSame('ghi@def@', $data['search_tags']);
- static::assertCount(1, $data['tags']);
+ if ('render_tagcloud' === $hook) {
+ static::assertSame('ghi@def@', $data['search_tags']);
+ static::assertCount(1, $data['tags']);
- static::assertArrayHasKey('loggedin', $param);
- }
+ static::assertArrayHasKey('loggedin', $param);
+ }
return $data;
})
diff --git a/tests/helper/ApplicationUtilsTest.php b/tests/helper/ApplicationUtilsTest.php
index 654857b9..1b4f8204 100644
--- a/tests/helper/ApplicationUtilsTest.php
+++ b/tests/helper/ApplicationUtilsTest.php
@@ -1,10 +1,9 @@
'. PHP_EOL);
+ file_put_contents('sandbox/version.php', '' . PHP_EOL);
$this->assertEquals(
'1.2.3',
ApplicationUtils::getVersion('sandbox/version.php', 1)
@@ -301,7 +300,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
$conf->set('resource.update_check', 'data/lastupdatecheck.txt');
$this->assertEquals(
- array(),
+ [],
ApplicationUtils::checkResourcePermissions($conf)
);
}
@@ -324,7 +323,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
$conf->set('resource.raintpl_theme', 'null/tpl/default');
$conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
$this->assertEquals(
- array(
+ [
'"null/tpl" directory is not readable',
'"null/tpl/default" directory is not readable',
'"null/cache" directory is not readable',
@@ -335,7 +334,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
'"null/pagecache" directory is not writable',
'"null/tmp" directory is not readable',
'"null/tmp" directory is not writable'
- ),
+ ],
ApplicationUtils::checkResourcePermissions($conf)
);
}
diff --git a/tests/helper/DailyPageHelperTest.php b/tests/helper/DailyPageHelperTest.php
index 2d745800..4a4b95b2 100644
--- a/tests/helper/DailyPageHelperTest.php
+++ b/tests/helper/DailyPageHelperTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Shaarli\Helper;
+use DateTime;
use DateTimeImmutable;
use DateTimeInterface;
use Shaarli\Bookmark\Bookmark;
@@ -147,7 +148,8 @@ class DailyPageHelperTest extends TestCase
/**
* @dataProvider getRssLengthsByType
*/
- public function testGeRssLengthsByType(string $type): void {
+ public function testGeRssLengthsByType(string $type): void
+ {
$length = DailyPageHelper::getRssLengthByType($type);
static::assertIsInt($length);
@@ -208,31 +210,31 @@ class DailyPageHelperTest extends TestCase
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'],
];
}
@@ -254,9 +256,9 @@ class DailyPageHelperTest extends TestCase
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')],
];
}
@@ -266,9 +268,9 @@ class DailyPageHelperTest extends TestCase
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')],
];
}
@@ -321,20 +323,20 @@ class DailyPageHelperTest extends TestCase
[
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'),
],
];
}
diff --git a/tests/http/HttpUtils/ClientIpIdTest.php b/tests/http/HttpUtils/ClientIpIdTest.php
index 3a0fcf30..acb2e9d4 100644
--- a/tests/http/HttpUtils/ClientIpIdTest.php
+++ b/tests/http/HttpUtils/ClientIpIdTest.php
@@ -1,12 +1,11 @@
assertFalse(getIpAddressFromProxy(array(), array()));
+ $this->assertFalse(getIpAddressFromProxy([], []));
}
/**
@@ -24,8 +22,8 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
public function testWithOneForwardedIp()
{
$ip = '1.1.1.1';
- $server = array('HTTP_X_FORWARDED_FOR' => $ip);
- $this->assertEquals($ip, getIpAddressFromProxy($server, array()));
+ $server = ['HTTP_X_FORWARDED_FOR' => $ip];
+ $this->assertEquals($ip, getIpAddressFromProxy($server, []));
}
/**
@@ -36,11 +34,11 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
$ip = '1.1.1.1';
$ip2 = '2.2.2.2';
- $server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
- $this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
+ $server = ['HTTP_X_FORWARDED_FOR' => $ip . ',' . $ip2];
+ $this->assertEquals($ip2, getIpAddressFromProxy($server, []));
- $server = array('HTTP_X_FORWARDED_FOR' => $ip .' , '. $ip2);
- $this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
+ $server = ['HTTP_X_FORWARDED_FOR' => $ip . ' , ' . $ip2];
+ $this->assertEquals($ip2, getIpAddressFromProxy($server, []));
}
/**
@@ -51,11 +49,11 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
$ip = '1.1.1.1';
$ip2 = '2.2.2.2';
- $server = array('HTTP_X_FORWARDED_FOR' => $ip);
- $this->assertFalse(getIpAddressFromProxy($server, array($ip)));
+ $server = ['HTTP_X_FORWARDED_FOR' => $ip];
+ $this->assertFalse(getIpAddressFromProxy($server, [$ip]));
- $server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
- $this->assertEquals($ip2, getIpAddressFromProxy($server, array($ip)));
- $this->assertFalse(getIpAddressFromProxy($server, array($ip, $ip2)));
+ $server = ['HTTP_X_FORWARDED_FOR' => $ip . ',' . $ip2];
+ $this->assertEquals($ip2, getIpAddressFromProxy($server, [$ip]));
+ $this->assertFalse(getIpAddressFromProxy($server, [$ip, $ip2]));
}
}
diff --git a/tests/http/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php
index f283d119..94b8ff8a 100644
--- a/tests/http/HttpUtils/IndexUrlTest.php
+++ b/tests/http/HttpUtils/IndexUrlTest.php
@@ -1,4 +1,5 @@
assertEquals(
'http://host.tld/',
index_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/index.php'
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/admin/',
index_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/index.php'
- )
+ ]
)
);
}
@@ -52,24 +51,24 @@ class IndexUrlTest extends TestCase
$this->assertEquals(
'http://host.tld/page.php',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/page.php'
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/admin/page.php',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/page.php'
- )
+ ]
)
);
}
@@ -82,26 +81,26 @@ class IndexUrlTest extends TestCase
$this->assertEquals(
'http://host.tld/picture-wall',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/index.php',
'REQUEST_URI' => '/picture-wall',
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/admin/picture-wall',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/index.php',
'REQUEST_URI' => '/admin/picture-wall',
- )
+ ]
)
);
}
@@ -114,26 +113,26 @@ class IndexUrlTest extends TestCase
$this->assertEquals(
'http://host.tld/subfolder/picture-wall',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/subfolder/index.php',
'REQUEST_URI' => '/subfolder/picture-wall',
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/subfolder/admin/picture-wall',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/subfolder/admin/index.php',
'REQUEST_URI' => '/subfolder/admin/picture-wall',
- )
+ ]
)
);
}
diff --git a/tests/http/HttpUtils/IndexUrlTestWithConstant.php b/tests/http/HttpUtils/IndexUrlTestWithConstant.php
index ecaea724..67c4668d 100644
--- a/tests/http/HttpUtils/IndexUrlTestWithConstant.php
+++ b/tests/http/HttpUtils/IndexUrlTestWithConstant.php
@@ -25,26 +25,26 @@ class IndexUrlTestWithConstant extends TestCase
$this->assertEquals(
'http://other-host.tld/subfolder/',
index_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/index.php',
'REQUEST_URI' => '/picture-wall',
- )
+ ]
)
);
$this->assertEquals(
'http://other-host.tld/subfolder/',
index_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/index.php',
'REQUEST_URI' => '/admin/picture-wall',
- )
+ ]
)
);
}
diff --git a/tests/http/HttpUtils/IsHttpsTest.php b/tests/http/HttpUtils/IsHttpsTest.php
index 8b3fd93d..f7c55587 100644
--- a/tests/http/HttpUtils/IsHttpsTest.php
+++ b/tests/http/HttpUtils/IsHttpsTest.php
@@ -2,8 +2,6 @@
namespace Shaarli\Http;
-require_once 'application/http/HttpUtils.php';
-
/**
* Class IsHttpsTest
*
diff --git a/tests/http/HttpUtils/PageUrlTest.php b/tests/http/HttpUtils/PageUrlTest.php
index ebb3e617..bf882e5b 100644
--- a/tests/http/HttpUtils/PageUrlTest.php
+++ b/tests/http/HttpUtils/PageUrlTest.php
@@ -1,12 +1,11 @@
assertEquals(
'http://host.tld/?p1=v1&p2=v2',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/index.php',
'QUERY_STRING' => 'p1=v1&p2=v2'
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/admin/?action=edit_tag',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/index.php',
'QUERY_STRING' => 'action=edit_tag'
- )
+ ]
)
);
}
@@ -52,26 +51,26 @@ class PageUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'http://host.tld/page.php?p1=v1&p2=v2',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/page.php',
'QUERY_STRING' => 'p1=v1&p2=v2'
- )
+ ]
)
);
$this->assertEquals(
'http://host.tld/admin/page.php?action=edit_tag',
page_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'SCRIPT_NAME' => '/admin/page.php',
'QUERY_STRING' => 'action=edit_tag'
- )
+ ]
)
);
}
diff --git a/tests/http/HttpUtils/ServerUrlTest.php b/tests/http/HttpUtils/ServerUrlTest.php
index 339664e1..5a4f9252 100644
--- a/tests/http/HttpUtils/ServerUrlTest.php
+++ b/tests/http/HttpUtils/ServerUrlTest.php
@@ -1,12 +1,11 @@
assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'ON',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '443'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld:8080',
server_url(
- array(
+ [
'HTTPS' => 'ON',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '8080'
- )
+ ]
)
);
}
@@ -48,22 +47,22 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'https://host.tld:8080',
server_url(
- array(
+ [
'HTTP_X_FORWARDED_PROTO' => 'https',
'HTTP_X_FORWARDED_PORT' => '8080',
'HTTP_X_FORWARDED_HOST' => 'host.tld'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld:4974',
server_url(
- array(
+ [
'HTTP_X_FORWARDED_PROTO' => 'https, https',
'HTTP_X_FORWARDED_PORT' => '4974, 80',
'HTTP_X_FORWARDED_HOST' => 'host.tld, example.com'
- )
+ ]
)
);
}
@@ -76,51 +75,51 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'https://host.tld:8080',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https',
'HTTP_X_FORWARDED_PORT' => '8080'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https',
'HTTP_X_FORWARDED_PORT' => '443'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld:4974',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https, https',
'HTTP_X_FORWARDED_PORT' => '4974, 80'
- )
+ ]
)
);
}
@@ -134,11 +133,11 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'http://host.tld:8080',
server_url(
- array(
+ [
'HTTPS' => 'OFF',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '8080'
- )
+ ]
)
);
@@ -146,11 +145,11 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'https://host.tld:8080',
server_url(
- array(
+ [
'HTTPS' => 'ON',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '8080'
- )
+ ]
)
);
}
@@ -163,11 +162,11 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'http://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'OFF',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80'
- )
+ ]
)
);
}
@@ -180,11 +179,11 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'ON',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '443'
- )
+ ]
)
);
}
@@ -197,26 +196,26 @@ class ServerUrlTest extends \Shaarli\TestCase
$this->assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'http',
'HTTP_X_FORWARDED_PORT' => '443'
- )
+ ]
)
);
$this->assertEquals(
'https://host.tld',
server_url(
- array(
+ [
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https, http',
'HTTP_X_FORWARDED_PORT' => '443, 80'
- )
+ ]
)
);
}
diff --git a/tests/http/MetadataRetrieverTest.php b/tests/http/MetadataRetrieverTest.php
index cae65091..bf63256a 100644
--- a/tests/http/MetadataRetrieverTest.php
+++ b/tests/http/MetadataRetrieverTest.php
@@ -66,7 +66,12 @@ class MetadataRetrieverTest extends TestCase
->expects(static::once())
->method('getCurlDownloadCallback')
->willReturnCallback(
- function (&$charset, &$title, &$description, &$tags) use (
+ function (
+ &$charset,
+ &$title,
+ &$description,
+ &$tags
+ ) use (
$remoteCharset,
$remoteTitle,
$remoteDesc,
@@ -95,7 +100,7 @@ class MetadataRetrieverTest extends TestCase
->expects(static::once())
->method('getHttpResponse')
->with($url, 30, 4194304)
- ->willReturnCallback(function($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
+ ->willReturnCallback(function ($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
$headerCallback();
$dlCallback();
})
@@ -124,7 +129,8 @@ class MetadataRetrieverTest extends TestCase
->method('getCurlDownloadCallback')
->willReturnCallback(
function (): callable {
- return function (): void {};
+ return function (): void {
+ };
}
)
;
@@ -133,7 +139,8 @@ class MetadataRetrieverTest extends TestCase
->method('getCurlHeaderCallback')
->willReturnCallback(
function (): callable {
- return function (): void {};
+ return function (): void {
+ };
}
)
;
@@ -141,7 +148,7 @@ class MetadataRetrieverTest extends TestCase
->expects(static::once())
->method('getHttpResponse')
->with($url, 30, 4194304)
- ->willReturnCallback(function($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
+ ->willReturnCallback(function ($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
$headerCallback();
$dlCallback();
})
diff --git a/tests/http/UrlTest.php b/tests/http/UrlTest.php
index c6b39c29..3bead6d7 100644
--- a/tests/http/UrlTest.php
+++ b/tests/http/UrlTest.php
@@ -1,4 +1,5 @@
assertEquals($this->ref, cleanup_url($this->ref));
- $this->ref2 = $this->ref.'/path/to/dir/';
+ $this->ref2 = $this->ref . '/path/to/dir/';
$this->assertEquals($this->ref2, cleanup_url($this->ref2));
}
@@ -38,9 +37,9 @@ class CleanupUrlTest extends \Shaarli\TestCase
*/
public function testCleanupUrlFragment()
{
- $this->assertEquals($this->ref, cleanup_url($this->ref.'#tk.rss_all'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'#xtor=RSS-'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'#xtor=RSS-U3ht0tkc4b'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '#tk.rss_all'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '#xtor=RSS-'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '#xtor=RSS-U3ht0tkc4b'));
}
/**
@@ -48,23 +47,23 @@ class CleanupUrlTest extends \Shaarli\TestCase
*/
public function testCleanupUrlQuerySingle()
{
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?action_object_map=junk'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?action_ref_map=Cr4p!'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?action_type_map=g4R84g3'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?action_object_map=junk'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?action_ref_map=Cr4p!'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?action_type_map=g4R84g3'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?fb_stuff=v41u3'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?fb=71m3w4573'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?fb_stuff=v41u3'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?fb=71m3w4573'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_campaign=zomg'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_medium=numnum'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_source=c0d3'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_term=1n4l'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?utm_campaign=zomg'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?utm_medium=numnum'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?utm_source=c0d3'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?utm_term=1n4l'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?xtor=some-url'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?xtor=some-url'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?campaign_name=junk'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?campaign_start=junk'));
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?campaign_item_index=junk'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?campaign_name=junk'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?campaign_start=junk'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?campaign_item_index=junk'));
}
/**
@@ -72,14 +71,14 @@ class CleanupUrlTest extends \Shaarli\TestCase
*/
public function testCleanupUrlQueryMultiple()
{
- $this->assertEquals($this->ref, cleanup_url($this->ref.'?xtor=some-url&fb=som3th1ng'));
+ $this->assertEquals($this->ref, cleanup_url($this->ref . '?xtor=some-url&fb=som3th1ng'));
$this->assertEquals($this->ref, cleanup_url(
- $this->ref.'?fb=stuff&utm_campaign=zomg&utm_medium=numnum&utm_source=c0d3'
+ $this->ref . '?fb=stuff&utm_campaign=zomg&utm_medium=numnum&utm_source=c0d3'
));
$this->assertEquals($this->ref, cleanup_url(
- $this->ref.'?campaign_start=zomg&campaign_name=numnum'
+ $this->ref . '?campaign_start=zomg&campaign_name=numnum'
));
}
@@ -89,22 +88,22 @@ class CleanupUrlTest extends \Shaarli\TestCase
public function testCleanupUrlQueryFragment()
{
$this->assertEquals($this->ref, cleanup_url(
- $this->ref.'?xtor=some-url&fb=som3th1ng#tk.rss_all'
+ $this->ref . '?xtor=some-url&fb=som3th1ng#tk.rss_all'
));
// ditch annoying query params and fragment, keep useful params
$this->assertEquals(
- $this->ref.'?my=stuff&is=kept',
+ $this->ref . '?my=stuff&is=kept',
cleanup_url(
- $this->ref.'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#tk.rss_all'
+ $this->ref . '?fb=zomg&my=stuff&utm_medium=numnum&is=kept#tk.rss_all'
)
);
// ditch annoying query params, keep useful params and fragment
$this->assertEquals(
- $this->ref.'?my=stuff&is=kept#again',
+ $this->ref . '?my=stuff&is=kept#again',
cleanup_url(
- $this->ref.'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#again'
+ $this->ref . '?fb=zomg&my=stuff&utm_medium=numnum&is=kept#again'
)
);
}
diff --git a/tests/http/UrlUtils/GetUrlSchemeTest.php b/tests/http/UrlUtils/GetUrlSchemeTest.php
index 18a9a5e5..a6eeff00 100644
--- a/tests/http/UrlUtils/GetUrlSchemeTest.php
+++ b/tests/http/UrlUtils/GetUrlSchemeTest.php
@@ -1,13 +1,14 @@
assertEquals('', unparse_url(array()));
+ $this->assertEquals('', unparse_url([]));
}
/**
@@ -26,7 +27,7 @@ class UnparseUrlTest extends \Shaarli\TestCase
public function testUnparseFull()
{
$ref = 'http://username:password@hostname:9090/path'
- .'?arg1=value1&arg2=value2#anchor';
+ . '?arg1=value1&arg2=value2#anchor';
$this->assertEquals($ref, unparse_url(parse_url($ref)));
}
}
diff --git a/tests/http/UrlUtils/WhitelistProtocolsTest.php b/tests/http/UrlUtils/WhitelistProtocolsTest.php
index b8a6baaa..673af32b 100644
--- a/tests/http/UrlUtils/WhitelistProtocolsTest.php
+++ b/tests/http/UrlUtils/WhitelistProtocolsTest.php
@@ -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).
@@ -30,7 +30,7 @@ class WhitelistProtocolsTest extends \Shaarli\TestCase
{
$whitelist = ['ftp', 'magnet'];
$url = 'test.tld/path/?query=value#hash';
- $this->assertEquals('http://'. $url, whitelist_protocols($url, $whitelist));
+ $this->assertEquals('http://' . $url, whitelist_protocols($url, $whitelist));
}
/**
diff --git a/tests/languages/bootstrap.php b/tests/languages/bootstrap.php
index da6ac2e4..69ade20e 100644
--- a/tests/languages/bootstrap.php
+++ b/tests/languages/bootstrap.php
@@ -1,4 +1,5 @@
assertFileNotExists(self::$testDatastore);
$checkDB = self::getMethod('check');
- $checkDB->invokeArgs($linkDB, array());
+ $checkDB->invokeArgs($linkDB, []);
$this->assertFileExists(self::$testDatastore);
// ensure the correct data has been written
@@ -135,7 +132,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
$this->assertGreaterThan(0, $datastoreSize);
$checkDB = self::getMethod('check');
- $checkDB->invokeArgs($linkDB, array());
+ $checkDB->invokeArgs($linkDB, []);
// ensure the datastore is left unmodified
$this->assertEquals(
@@ -185,7 +182,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
$testDB = new LegacyLinkDB(self::$testDatastore, true, false);
$dbSize = sizeof($testDB);
- $link = array(
+ $link = [
'id' => 43,
'title' => 'an additional link',
'url' => 'http://dum.my',
@@ -193,7 +190,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
'private' => 0,
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150518_190000'),
'tags' => 'unit test'
- );
+ ];
$testDB[$link['id']] = $link;
$testDB->save('tests');
@@ -239,12 +236,12 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
public function testDays()
{
$this->assertEquals(
- array('20100309', '20100310', '20121206', '20121207', '20130614', '20150310'),
+ ['20100309', '20100310', '20121206', '20121207', '20130614', '20150310'],
self::$publicLinkDB->days()
);
$this->assertEquals(
- array('20100309', '20100310', '20121206', '20121207', '20130614', '20141125', '20150310'),
+ ['20100309', '20100310', '20121206', '20121207', '20130614', '20141125', '20150310'],
self::$privateLinkDB->days()
);
}
@@ -280,7 +277,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
public function testAllTags()
{
$this->assertEquals(
- array(
+ [
'web' => 3,
'cartoon' => 2,
'gnu' => 2,
@@ -300,12 +297,12 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
'coding-style' => 1,
'quality' => 1,
'standards' => 1,
- ),
+ ],
self::$publicLinkDB->linksCountPerTag()
);
$this->assertEquals(
- array(
+ [
'web' => 4,
'cartoon' => 3,
'gnu' => 2,
@@ -332,11 +329,11 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
'coding-style' => 1,
'quality' => 1,
'standards' => 1,
- ),
+ ],
self::$privateLinkDB->linksCountPerTag()
);
$this->assertEquals(
- array(
+ [
'web' => 4,
'cartoon' => 2,
'gnu' => 1,
@@ -349,17 +346,17 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
'Mercurial' => 1,
'.hidden' => 1,
'hashtag' => 1,
- ),
+ ],
self::$privateLinkDB->linksCountPerTag(['web'])
);
$this->assertEquals(
- array(
+ [
'web' => 1,
'html' => 1,
'w3c' => 1,
'css' => 1,
'Mercurial' => 1,
- ),
+ ],
self::$privateLinkDB->linksCountPerTag(['web'], 'private')
);
}
@@ -370,7 +367,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
public function testFilterString()
{
$tags = 'dev cartoon';
- $request = array('searchtags' => $tags);
+ $request = ['searchtags' => $tags];
$this->assertEquals(
2,
count(self::$privateLinkDB->filterSearch($request, true, false))
@@ -382,8 +379,8 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
*/
public function testFilterArray()
{
- $tags = array('dev', 'cartoon');
- $request = array('searchtags' => $tags);
+ $tags = ['dev', 'cartoon'];
+ $request = ['searchtags' => $tags];
$this->assertEquals(
2,
count(self::$privateLinkDB->filterSearch($request, true, false))
@@ -397,7 +394,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
public function testHiddenTags()
{
$tags = '.hidden';
- $request = array('searchtags' => $tags);
+ $request = ['searchtags' => $tags];
$this->assertEquals(
1,
count(self::$privateLinkDB->filterSearch($request, true, false))
@@ -639,7 +636,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
for ($i = 0; $i < 4; ++$i) {
$linkDB[$nextId + $i] = [
'id' => $nextId + $i,
- 'url' => 'http://'. $i,
+ 'url' => 'http://' . $i,
'created' => $creation,
'title' => true,
'description' => true,
@@ -657,7 +654,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
continue;
}
$this->assertEquals($nextId + $count, $link['id']);
- $this->assertEquals('http://'. $count, $link['url']);
+ $this->assertEquals('http://' . $count, $link['url']);
if (--$count < 0) {
break;
}
diff --git a/tests/legacy/LegacyLinkFilterTest.php b/tests/legacy/LegacyLinkFilterTest.php
index 45d7754d..78e27a7b 100644
--- a/tests/legacy/LegacyLinkFilterTest.php
+++ b/tests/legacy/LegacyLinkFilterTest.php
@@ -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.
@@ -450,28 +449,28 @@ class LegacyLinkFilterTest extends \Shaarli\TestCase
1,
count(self::$linkFilter->filter(
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
- array($tags, $terms)
+ [$tags, $terms]
))
);
$this->assertEquals(
2,
count(self::$linkFilter->filter(
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
- array('', $terms)
+ ['', $terms]
))
);
$this->assertEquals(
1,
count(self::$linkFilter->filter(
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
- array(false, 'PSR-2')
+ [false, 'PSR-2']
))
);
$this->assertEquals(
1,
count(self::$linkFilter->filter(
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
- array($tags, '')
+ [$tags, '']
))
);
$this->assertEquals(
diff --git a/tests/legacy/LegacyUpdaterTest.php b/tests/legacy/LegacyUpdaterTest.php
index 395dd4b7..293fa719 100644
--- a/tests/legacy/LegacyUpdaterTest.php
+++ b/tests/legacy/LegacyUpdaterTest.php
@@ -1,4 +1,5 @@
conf = new ConfigManager(self::$configFile);
}
@@ -51,10 +50,10 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
*/
public function testReadEmptyUpdatesFile()
{
- $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
+ $this->assertEquals([], UpdaterUtils::readUpdatesFile(''));
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
- $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
+ $this->assertEquals([], UpdaterUtils::readUpdatesFile($updatesFile));
unlink($updatesFile);
}
@@ -64,7 +63,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
public function testReadWriteUpdatesFile()
{
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
- $updatesMethods = array('m1', 'm2', 'm3');
+ $updatesMethods = ['m1', 'm2', 'm3'];
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
@@ -86,7 +85,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
- UpdaterUtils::writeUpdatesFile('', array('test'));
+ UpdaterUtils::writeUpdatesFile('', ['test']);
}
/**
@@ -101,7 +100,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
touch($updatesFile);
chmod($updatesFile, 0444);
try {
- @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
+ @UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
} catch (Exception $e) {
unlink($updatesFile);
throw $e;
@@ -115,17 +114,17 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
*/
public function testNoUpdates()
{
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
'updateMethodException',
- );
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
- $this->assertEquals(array(), $updater->update());
+ ];
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
+ $this->assertEquals([], $updater->update());
- $updater = new DummyUpdater(array(), array(), $this->conf, false);
- $this->assertEquals(array(), $updater->update());
+ $updater = new DummyUpdater([], [], $this->conf, false);
+ $this->assertEquals([], $updater->update());
}
/**
@@ -133,13 +132,13 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
*/
public function testUpdatesFirstTime()
{
- $updates = array('updateMethodException',);
- $expectedUpdates = array(
+ $updates = ['updateMethodException',];
+ $expectedUpdates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
- );
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ ];
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$this->assertEquals($expectedUpdates, $updater->update());
}
@@ -148,14 +147,14 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
*/
public function testOneUpdate()
{
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy3',
'updateMethodException',
- );
- $expectedUpdate = array('updateMethodDummy2');
+ ];
+ $expectedUpdate = ['updateMethodDummy2'];
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$this->assertEquals($expectedUpdate, $updater->update());
}
@@ -166,13 +165,13 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
{
$this->expectException(\Exception::class);
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
- );
+ ];
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$updater->update();
}
@@ -197,7 +196,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$this->conf->setConfigFile('tests/updater/config');
// merge configs
- $updater = new LegacyUpdater(array(), array(), $this->conf, true);
+ $updater = new LegacyUpdater([], [], $this->conf, true);
// This writes a new config file in tests/updater/config.php
$updater->updateMethodMergeDeprecatedConfigFile();
@@ -214,7 +213,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
*/
public function testMergeDeprecatedConfigNoFile()
{
- $updater = new LegacyUpdater(array(), array(), $this->conf, true);
+ $updater = new LegacyUpdater([], [], $this->conf, true);
$updater->updateMethodMergeDeprecatedConfigFile();
$this->assertEquals('root', $this->conf->get('credentials.login'));
@@ -225,14 +224,14 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
*/
public function testRenameDashTags()
{
- $refDB = new \ReferenceLinkDB(true);
+ $refDB = new ReferenceLinkDB(true);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
- $this->assertEmpty($linkDB->filterSearch(array('searchtags' => 'exclude')));
- $updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
+ $this->assertEmpty($linkDB->filterSearch(['searchtags' => 'exclude']));
+ $updater = new LegacyUpdater([], $linkDB, $this->conf, true);
$updater->updateMethodRenameDashTags();
- $this->assertNotEmpty($linkDB->filterSearch(array('searchtags' => 'exclude')));
+ $this->assertNotEmpty($linkDB->filterSearch(['searchtags' => 'exclude']));
}
/**
@@ -247,7 +246,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
// The ConfigIO is initialized with ConfigPhp.
$this->assertTrue($this->conf->getConfigIO() instanceof ConfigPhp);
- $updater = new LegacyUpdater(array(), array(), $this->conf, false);
+ $updater = new LegacyUpdater([], [], $this->conf, false);
$done = $updater->updateMethodConfigToJson();
$this->assertTrue($done);
@@ -272,7 +271,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
public function testConfigToJsonNothingToDo()
{
$filetime = filemtime($this->conf->getConfigFileExt());
- $updater = new LegacyUpdater(array(), array(), $this->conf, false);
+ $updater = new LegacyUpdater([], [], $this->conf, false);
$done = $updater->updateMethodConfigToJson();
$this->assertTrue($done);
$expected = filemtime($this->conf->getConfigFileExt());
@@ -291,7 +290,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$headerLink = '';
$this->conf->set('general.title', $title);
$this->conf->set('general.header_link', $headerLink);
- $updater = new LegacyUpdater(array(), array(), $this->conf, true);
+ $updater = new LegacyUpdater([], [], $this->conf, true);
$done = $updater->updateMethodEscapeUnescapedConfig();
$this->assertTrue($done);
$this->conf->reload();
@@ -306,9 +305,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
public function testUpdateApiSettings()
{
$confFile = 'sandbox/config';
- copy(self::$configFile .'.json.php', $confFile .'.json.php');
+ copy(self::$configFile . '.json.php', $confFile . '.json.php');
$conf = new ConfigManager($confFile);
- $updater = new LegacyUpdater(array(), array(), $conf, true);
+ $updater = new LegacyUpdater([], [], $conf, true);
$this->assertFalse($conf->exists('api.enabled'));
$this->assertFalse($conf->exists('api.secret'));
@@ -316,7 +315,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$conf->reload();
$this->assertTrue($conf->get('api.enabled'));
$this->assertTrue($conf->exists('api.secret'));
- unlink($confFile .'.json.php');
+ unlink($confFile . '.json.php');
}
/**
@@ -325,15 +324,15 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
public function testUpdateApiSettingsNothingToDo()
{
$confFile = 'sandbox/config';
- copy(self::$configFile .'.json.php', $confFile .'.json.php');
+ copy(self::$configFile . '.json.php', $confFile . '.json.php');
$conf = new ConfigManager($confFile);
$conf->set('api.enabled', false);
$conf->set('api.secret', '');
- $updater = new LegacyUpdater(array(), array(), $conf, true);
+ $updater = new LegacyUpdater([], [], $conf, true);
$updater->updateMethodApiSettings();
$this->assertFalse($conf->get('api.enabled'));
$this->assertEmpty($conf->get('api.secret'));
- unlink($confFile .'.json.php');
+ unlink($confFile . '.json.php');
}
/**
@@ -341,8 +340,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
*/
public function testDatastoreIds()
{
- $links = array(
- '20121206_182539' => array(
+ $links = [
+ '20121206_182539' => [
'linkdate' => '20121206_182539',
'title' => 'Geek and Poke',
'url' => 'http://geek-and-poke.com/',
@@ -350,25 +349,25 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
'tags' => 'dev cartoon tag1 tag2 tag3 tag4 ',
'updated' => '20121206_190301',
'private' => false,
- ),
- '20121206_172539' => array(
+ ],
+ '20121206_172539' => [
'linkdate' => '20121206_172539',
'title' => 'UserFriendly - Samba',
'url' => 'http://ars.userfriendly.org/cartoons/?id=20010306',
'description' => '',
'tags' => 'samba cartoon web',
'private' => false,
- ),
- '20121206_142300' => array(
+ ],
+ '20121206_142300' => [
'linkdate' => '20121206_142300',
'title' => 'UserFriendly - Web Designer',
'url' => 'http://ars.userfriendly.org/cartoons/?id=20121206',
'description' => 'Naming conventions... #private',
'tags' => 'samba cartoon web',
'private' => true,
- ),
- );
- $refDB = new \ReferenceLinkDB(true);
+ ],
+ ];
+ $refDB = new ReferenceLinkDB(true);
$refDB->setLinks($links);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@@ -378,12 +377,12 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$this->conf->set('resource.data_dir', 'sandbox');
$this->conf->set('resource.datastore', self::$testDatastore);
- $updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
+ $updater = new LegacyUpdater([], $linkDB, $this->conf, true);
$this->assertTrue($updater->updateMethodDatastoreIds());
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
- $backupFiles = glob($this->conf->get('resource.data_dir') . '/datastore.'. date('YmdH') .'*.php');
+ $backupFiles = glob($this->conf->get('resource.data_dir') . '/datastore.' . date('YmdH') . '*.php');
$backup = null;
foreach ($backupFiles as $backupFile) {
if (strpos($backupFile, '_1') === false) {
@@ -437,7 +436,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
*/
public function testDatastoreIdsNothingToDo()
{
- $refDB = new \ReferenceLinkDB(true);
+ $refDB = new ReferenceLinkDB(true);
$refDB->write(self::$testDatastore);
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@@ -445,7 +444,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$this->conf->set('resource.datastore', self::$testDatastore);
$checksum = hash_file('sha1', self::$testDatastore);
- $updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
+ $updater = new LegacyUpdater([], $linkDB, $this->conf, true);
$this->assertTrue($updater->updateMethodDatastoreIds());
$this->assertEquals($checksum, hash_file('sha1', self::$testDatastore));
}
@@ -478,9 +477,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$sandbox = 'sandbox/config';
copy(self::$configFile . '.json.php', $sandbox . '.json.php');
$this->conf = new ConfigManager($sandbox);
- mkdir('sandbox/'. $theme);
- touch('sandbox/'. $theme .'/linklist.html');
- $this->conf->set('resource.raintpl_tpl', 'sandbox/'. $theme .'/');
+ mkdir('sandbox/' . $theme);
+ touch('sandbox/' . $theme . '/linklist.html');
+ $this->conf->set('resource.raintpl_tpl', 'sandbox/' . $theme . '/');
$updater = new LegacyUpdater([], [], $this->conf, true);
$this->assertTrue($updater->updateMethodDefaultTheme());
@@ -490,8 +489,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$this->assertEquals('sandbox', $this->conf->get('resource.raintpl_tpl'));
$this->assertEquals($theme, $this->conf->get('resource.theme'));
unlink($sandbox . '.json.php');
- unlink('sandbox/'. $theme .'/linklist.html');
- rmdir('sandbox/'. $theme);
+ unlink('sandbox/' . $theme . '/linklist.html');
+ rmdir('sandbox/' . $theme);
}
/**
@@ -572,11 +571,11 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$this->conf->set('plugins.PIWIK_URL', $url);
$updater = new LegacyUpdater([], [], $this->conf, true);
$this->assertTrue($updater->updateMethodPiwikUrl());
- $this->assertEquals('http://'. $url, $this->conf->get('plugins.PIWIK_URL'));
+ $this->assertEquals('http://' . $url, $this->conf->get('plugins.PIWIK_URL'));
// reload from file
$this->conf = new ConfigManager($sandboxConf);
- $this->assertEquals('http://'. $url, $this->conf->get('plugins.PIWIK_URL'));
+ $this->assertEquals('http://' . $url, $this->conf->get('plugins.PIWIK_URL'));
}
/**
@@ -781,12 +780,12 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
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);
- $updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
+ $updater = new LegacyUpdater([], $linkDB, $this->conf, true);
$this->assertTrue($updater->updateMethodSetSticky());
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
@@ -812,12 +811,12 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
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);
- $updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
+ $updater = new LegacyUpdater([], $linkDB, $this->conf, true);
$this->assertTrue($updater->updateMethodSetSticky());
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
diff --git a/tests/netscape/BookmarkExportTest.php b/tests/netscape/BookmarkExportTest.php
index b8a88cd8..ce054286 100644
--- a/tests/netscape/BookmarkExportTest.php
+++ b/tests/netscape/BookmarkExportTest.php
@@ -10,8 +10,7 @@ use Shaarli\Formatter\FormatterFactory;
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 @@ class BookmarkExportTest extends TestCase
$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);
diff --git a/tests/netscape/BookmarkImportTest.php b/tests/netscape/BookmarkImportTest.php
index ecd33ea1..d880c3aa 100644
--- a/tests/netscape/BookmarkImportTest.php
+++ b/tests/netscape/BookmarkImportTest.php
@@ -135,7 +135,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('empty.htm');
$this->assertEquals(
'File empty.htm (0 bytes) has an unknown file format.'
- .' Nothing was imported.',
+ . ' Nothing was imported.',
$this->netscapeBookmarkUtils->import(null, $files)
);
$this->assertEquals(0, $this->bookmarkService->count());
@@ -162,7 +162,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('lowercase_doctype.htm');
$this->assertStringMatchesFormat(
'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import(null, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -177,7 +177,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('internet_explorer_encoding.htm');
$this->assertStringMatchesFormat(
'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
- .' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 1 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import([], $files)
);
$this->assertEquals(1, $this->bookmarkService->count());
@@ -205,7 +205,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('netscape_nested.htm');
$this->assertStringMatchesFormat(
'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
- .' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 8 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import([], $files)
);
$this->assertEquals(8, $this->bookmarkService->count());
@@ -326,7 +326,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import([], $files)
);
@@ -365,11 +365,11 @@ class BookmarkImportTest extends TestCase
*/
public function testImportKeepPrivacy()
{
- $post = array('privacy' => 'default');
+ $post = ['privacy' => 'default'];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
@@ -408,11 +408,11 @@ class BookmarkImportTest extends TestCase
*/
public function testImportAsPublic()
{
- $post = array('privacy' => 'public');
+ $post = ['privacy' => 'public'];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -426,11 +426,11 @@ class BookmarkImportTest extends TestCase
*/
public function testImportAsPrivate()
{
- $post = array('privacy' => 'private');
+ $post = ['privacy' => 'private'];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -447,10 +447,10 @@ class BookmarkImportTest extends TestCase
$files = file2array('netscape_basic.htm');
// import bookmarks as private
- $post = array('privacy' => 'private');
+ $post = ['privacy' => 'private'];
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -459,13 +459,13 @@ class BookmarkImportTest extends TestCase
$this->assertTrue($this->bookmarkService->get(1)->isPrivate());
// re-import as public, enable overwriting
- $post = array(
+ $post = [
'privacy' => 'public',
'overwrite' => 'true'
- );
+ ];
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -482,10 +482,10 @@ class BookmarkImportTest extends TestCase
$files = file2array('netscape_basic.htm');
// import bookmarks as public
- $post = array('privacy' => 'public');
+ $post = ['privacy' => 'public'];
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -494,13 +494,13 @@ class BookmarkImportTest extends TestCase
$this->assertFalse($this->bookmarkService->get(1)->isPrivate());
// re-import as private, enable overwriting
- $post = array(
+ $post = [
'privacy' => 'private',
'overwrite' => 'true'
- );
+ ];
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 2 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -514,21 +514,21 @@ class BookmarkImportTest extends TestCase
*/
public function testSkipOverwrite()
{
- $post = array('privacy' => 'public');
+ $post = ['privacy' => 'public'];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
// re-import as private, DO NOT enable overwriting
- $post = array('privacy' => 'private');
+ $post = ['privacy' => 'private'];
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.',
+ . ' 0 bookmarks imported, 0 bookmarks overwritten, 2 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -540,14 +540,14 @@ class BookmarkImportTest extends TestCase
*/
public function testSetDefaultTags()
{
- $post = array(
+ $post = [
'privacy' => 'public',
'default_tags' => 'tag1 tag2 tag3'
- );
+ ];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -561,14 +561,14 @@ class BookmarkImportTest extends TestCase
*/
public function testSanitizeDefaultTags()
{
- $post = array(
+ $post = [
'privacy' => 'public',
'default_tags' => 'tag1& tag2 "tag3"'
- );
+ ];
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -597,7 +597,7 @@ class BookmarkImportTest extends TestCase
$files = file2array('netscape_basic.htm');
$this->assertStringMatchesFormat(
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
- .' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ . ' 2 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
$this->netscapeBookmarkUtils->import($post, $files)
);
$this->assertEquals(2, $this->bookmarkService->count());
@@ -630,8 +630,8 @@ class BookmarkImportTest extends TestCase
$files = file2array('same_date.htm');
$this->assertStringMatchesFormat(
'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
- .' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
- $this->netscapeBookmarkUtils->import(array(), $files)
+ . ' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
+ $this->netscapeBookmarkUtils->import([], $files)
);
$this->assertEquals(3, $this->bookmarkService->count());
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php
index a3ec9fc9..3ae72d99 100644
--- a/tests/plugins/PluginAddlinkTest.php
+++ b/tests/plugins/PluginAddlinkTest.php
@@ -1,4 +1,5 @@
$str);
+ $data = [$str => $str];
$data['_PAGE_'] = TemplatePage::LINKLIST;
$data['_LOGGEDIN_'] = true;
$data['_BASE_PATH_'] = '/subfolder';
@@ -34,7 +35,7 @@ class PluginAddlinkTest extends \Shaarli\TestCase
$this->assertEquals($str, $data[$str]);
$this->assertEquals(1, count($data['fields_toolbar']));
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = $str;
$data['_LOGGEDIN_'] = true;
$data['_BASE_PATH_'] = '/subfolder';
@@ -50,7 +51,7 @@ class PluginAddlinkTest extends \Shaarli\TestCase
public function testAddlinkHeaderLoggedOut()
{
$str = 'stuff';
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = TemplatePage::LINKLIST;
$data['_LOGGEDIN_'] = false;
$data['_BASE_PATH_'] = '/subfolder';
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php
index 467dc3d0..909be088 100644
--- a/tests/plugins/PluginArchiveorgTest.php
+++ b/tests/plugins/PluginArchiveorgTest.php
@@ -2,10 +2,6 @@
namespace Shaarli\Plugin\Archiveorg;
-/**
- * PluginArchiveorgTest.php
- */
-
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
@@ -47,16 +43,16 @@ class PluginArchiveorgTest extends TestCase
{
$str = 'http://randomstr.com/test';
- $data = array(
+ $data = [
'title' => $str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'url' => $str,
'private' => 0,
'real_url' => $str
- )
- )
- );
+ ]
+ ]
+ ];
$data = hook_archiveorg_render_linklist($data);
@@ -84,41 +80,41 @@ class PluginArchiveorgTest extends TestCase
$internalLink3 = 'http://shaarli.shaarli/shaare/z7u-_Q';
$internalLinkRealURL3 = '/shaare/z7u-_Q';
- $data = array(
+ $data = [
'title' => $internalLink1,
- 'links' => array(
- array(
+ 'links' => [
+ [
'url' => $internalLink1,
'private' => 0,
'real_url' => $internalLinkRealURL1
- ),
- array(
+ ],
+ [
'url' => $internalLink1,
'private' => 1,
'real_url' => $internalLinkRealURL1
- ),
- array(
+ ],
+ [
'url' => $internalLink2,
'private' => 0,
'real_url' => $internalLinkRealURL2
- ),
- array(
+ ],
+ [
'url' => $internalLink2,
'private' => 1,
'real_url' => $internalLinkRealURL2
- ),
- array(
+ ],
+ [
'url' => $internalLink3,
'private' => 0,
'real_url' => $internalLinkRealURL3
- ),
- array(
+ ],
+ [
'url' => $internalLink3,
'private' => 1,
'real_url' => $internalLinkRealURL3
- )
- )
- );
+ ]
+ ]
+ ];
$data = hook_archiveorg_render_linklist($data);
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index 16ecf357..119a459e 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -1,4 +1,5 @@
$str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'id' => 12,
'url' => $str,
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
- )
- )
- );
+ ]
+ ]
+ ];
$data = hook_isso_render_linklist($data, $conf);
@@ -76,11 +77,11 @@ class PluginIssoTest extends TestCase
$this->assertEquals(1, count($data['plugin_end_zone']));
$this->assertNotFalse(strpos(
$data['plugin_end_zone'][0],
- 'data-isso-id="'. $data['links'][0]['id'] .'"'
+ 'data-isso-id="' . $data['links'][0]['id'] . '"'
));
$this->assertNotFalse(strpos(
$data['plugin_end_zone'][0],
- 'data-title="'. $data['links'][0]['id'] .'"'
+ 'data-title="' . $data['links'][0]['id'] . '"'
));
$this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
}
@@ -96,28 +97,34 @@ class PluginIssoTest extends TestCase
$str = 'http://randomstr.com/test';
$date1 = '20161118_100001';
$date2 = '20161118_100002';
- $data = array(
+ $data = [
'title' => $str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'id' => 12,
'url' => $str,
'shorturl' => $short1 = 'abcd',
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date1),
- ),
- array(
+ ],
+ [
'id' => 13,
'url' => $str . '2',
'shorturl' => $short2 = 'efgh',
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date2),
- ),
- )
- );
+ ],
+ ]
+ ];
$processed = hook_isso_render_linklist($data, $conf);
// link_plugin should be added for the icon
- $this->assertContainsPolyfill('
', $processed['links'][0]['link_plugin'][0]);
- $this->assertContainsPolyfill('', $processed['links'][1]['link_plugin'][0]);
+ $this->assertContainsPolyfill(
+ '',
+ $processed['links'][0]['link_plugin'][0]
+ );
+ $this->assertContainsPolyfill(
+ '',
+ $processed['links'][1]['link_plugin'][0]
+ );
}
/**
@@ -130,23 +137,26 @@ class PluginIssoTest extends TestCase
$str = 'http://randomstr.com/test';
$date = '20161118_100001';
- $data = array(
+ $data = [
'title' => $str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'id' => 12,
'url' => $str,
'shorturl' => $short1 = 'abcd',
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
- )
- ),
+ ]
+ ],
'search_term' => $str
- );
+ ];
$processed = hook_isso_render_linklist($data, $conf);
// link_plugin should be added for the icon
- $this->assertContainsPolyfill('', $processed['links'][0]['link_plugin'][0]);
+ $this->assertContainsPolyfill(
+ '',
+ $processed['links'][0]['link_plugin'][0]
+ );
}
/**
diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php
index 338d2e35..0f267462 100644
--- a/tests/plugins/PluginPlayvideosTest.php
+++ b/tests/plugins/PluginPlayvideosTest.php
@@ -1,9 +1,6 @@
$str);
+ $data = [$str => $str];
$data['_PAGE_'] = TemplatePage::LINKLIST;
$data = hook_playvideos_render_header($data);
$this->assertEquals($str, $data[$str]);
$this->assertEquals(1, count($data['buttons_toolbar']));
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = $str;
$this->assertEquals($str, $data[$str]);
$this->assertArrayNotHasKey('buttons_toolbar', $data);
@@ -49,14 +46,14 @@ class PluginPlayvideosTest extends \Shaarli\TestCase
public function testPlayvideosFooter()
{
$str = 'stuff';
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = TemplatePage::LINKLIST;
$data = hook_playvideos_render_footer($data);
$this->assertEquals($str, $data[$str]);
$this->assertEquals(2, count($data['js_files']));
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = $str;
$this->assertEquals($str, $data[$str]);
$this->assertArrayNotHasKey('js_files', $data);
diff --git a/tests/plugins/PluginPubsubhubbubTest.php b/tests/plugins/PluginPubsubhubbubTest.php
index d3f7b439..9fa944c1 100644
--- a/tests/plugins/PluginPubsubhubbubTest.php
+++ b/tests/plugins/PluginPubsubhubbubTest.php
@@ -1,4 +1,5 @@
';
+ $expected = '';
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
}
@@ -52,7 +53,7 @@ class PluginPubsubhubbubTest extends \Shaarli\TestCase
$data['_PAGE_'] = TemplatePage::FEED_ATOM;
$data = hook_pubsubhubbub_render_feed($data, $conf);
- $expected = '';
+ $expected = '';
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
}
}
diff --git a/tests/plugins/PluginQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php
index 1d85fba6..ff4b9182 100644
--- a/tests/plugins/PluginQrcodeTest.php
+++ b/tests/plugins/PluginQrcodeTest.php
@@ -1,9 +1,6 @@
$str,
- 'links' => array(
- array(
+ 'links' => [
+ [
'url' => $str,
- )
- )
- );
+ ]
+ ]
+ ];
$data = hook_qrcode_render_linklist($data);
$link = $data['links'][0];
@@ -56,14 +53,14 @@ class PluginQrcodeTest extends \Shaarli\TestCase
public function testQrcodeFooter()
{
$str = 'stuff';
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = TemplatePage::LINKLIST;
$data = hook_qrcode_render_footer($data);
$this->assertEquals($str, $data[$str]);
$this->assertEquals(1, count($data['js_files']));
- $data = array($str => $str);
+ $data = [$str => $str];
$data['_PAGE_'] = $str;
$this->assertEquals($str, $data[$str]);
$this->assertArrayNotHasKey('js_files', $data);
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php
index 9a402fb7..0be8d59a 100644
--- a/tests/plugins/PluginWallabagTest.php
+++ b/tests/plugins/PluginWallabagTest.php
@@ -1,4 +1,5 @@
assertFalse(in_array('supertheme', $res));
foreach ($themes as $theme) {
- rmdir('sandbox/tpl/'. $theme);
+ rmdir('sandbox/tpl/' . $theme);
}
unlink('sandbox/tpl/supertheme');
rmdir('sandbox/tpl');
diff --git a/tests/security/BanManagerTest.php b/tests/security/BanManagerTest.php
index 29d2791b..31b8cdd5 100644
--- a/tests/security/BanManagerTest.php
+++ b/tests/security/BanManagerTest.php
@@ -1,6 +1,5 @@
configManager->set('ldap.host', 'dummy');
$this->assertFalse(
- $this->loginManager->checkCredentialsFromLdap($this->login, $this->password, function() { return null; }, function() { return false; })
+ $this->loginManager->checkCredentialsFromLdap($this->login, $this->password, function () {
+ return null;
+ }, function () {
+ return false;
+ })
);
}
@@ -360,7 +364,11 @@ class LoginManagerTest extends TestCase
{
$this->configManager->set('ldap.host', 'dummy');
$this->assertTrue(
- $this->loginManager->checkCredentialsFromLdap($this->login, $this->password, function() { return null; }, function() { return true; })
+ $this->loginManager->checkCredentialsFromLdap($this->login, $this->password, function () {
+ return null;
+ }, function () {
+ return true;
+ })
);
}
}
diff --git a/tests/security/SessionManagerTest.php b/tests/security/SessionManagerTest.php
index 6830d714..7cc6e1a4 100644
--- a/tests/security/SessionManagerTest.php
+++ b/tests/security/SessionManagerTest.php
@@ -4,6 +4,7 @@ namespace Shaarli\Security;
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();
}
/**
diff --git a/tests/updater/DummyUpdater.php b/tests/updater/DummyUpdater.php
index 3403233f..93e63c92 100644
--- a/tests/updater/DummyUpdater.php
+++ b/tests/updater/DummyUpdater.php
@@ -1,5 +1,6 @@
refDB = new \ReferenceLinkDB();
+ $this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
- copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
+ copy('tests/utils/config/configJson.json.php', self::$configFile . '.json.php');
$this->conf = new ConfigManager(self::$configFile);
$this->bookmarkService = new BookmarkFileService(
$this->conf,
@@ -67,10 +69,10 @@ class UpdaterTest extends TestCase
*/
public function testReadEmptyUpdatesFile()
{
- $this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
+ $this->assertEquals([], UpdaterUtils::readUpdatesFile(''));
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile);
- $this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
+ $this->assertEquals([], UpdaterUtils::readUpdatesFile($updatesFile));
unlink($updatesFile);
}
@@ -80,7 +82,7 @@ class UpdaterTest extends TestCase
public function testReadWriteUpdatesFile()
{
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
- $updatesMethods = array('m1', 'm2', 'm3');
+ $updatesMethods = ['m1', 'm2', 'm3'];
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
@@ -102,7 +104,7 @@ class UpdaterTest extends TestCase
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
- UpdaterUtils::writeUpdatesFile('', array('test'));
+ UpdaterUtils::writeUpdatesFile('', ['test']);
}
/**
@@ -117,7 +119,7 @@ class UpdaterTest extends TestCase
touch($updatesFile);
chmod($updatesFile, 0444);
try {
- @UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
+ @UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
} catch (Exception $e) {
unlink($updatesFile);
throw $e;
@@ -131,17 +133,17 @@ class UpdaterTest extends TestCase
*/
public function testNoUpdates()
{
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
'updateMethodException',
- );
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
- $this->assertEquals(array(), $updater->update());
+ ];
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
+ $this->assertEquals([], $updater->update());
- $updater = new DummyUpdater(array(), array(), $this->conf, false);
- $this->assertEquals(array(), $updater->update());
+ $updater = new DummyUpdater([], [], $this->conf, false);
+ $this->assertEquals([], $updater->update());
}
/**
@@ -149,13 +151,13 @@ class UpdaterTest extends TestCase
*/
public function testUpdatesFirstTime()
{
- $updates = array('updateMethodException',);
- $expectedUpdates = array(
+ $updates = ['updateMethodException',];
+ $expectedUpdates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
- );
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ ];
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$this->assertEquals($expectedUpdates, $updater->update());
}
@@ -164,14 +166,14 @@ class UpdaterTest extends TestCase
*/
public function testOneUpdate()
{
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy3',
'updateMethodException',
- );
- $expectedUpdate = array('updateMethodDummy2');
+ ];
+ $expectedUpdate = ['updateMethodDummy2'];
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$this->assertEquals($expectedUpdate, $updater->update());
}
@@ -182,13 +184,13 @@ class UpdaterTest extends TestCase
{
$this->expectException(\Exception::class);
- $updates = array(
+ $updates = [
'updateMethodDummy1',
'updateMethodDummy2',
'updateMethodDummy3',
- );
+ ];
- $updater = new DummyUpdater($updates, array(), $this->conf, true);
+ $updater = new DummyUpdater($updates, [], $this->conf, true);
$updater->update();
}
diff --git a/tests/utils/CurlUtils.php b/tests/utils/CurlUtils.php
index 1cc4907e..0c9c1fb2 100644
--- a/tests/utils/CurlUtils.php
+++ b/tests/utils/CurlUtils.php
@@ -1,4 +1,5 @@
$id,
'title' => $title,
'url' => $url,
@@ -175,7 +178,7 @@ class ReferenceLinkDB
'updated' => $updated,
'shorturl' => $shorturl ? $shorturl : smallHash($date->format(Bookmark::LINK_DATE_FORMAT) . $id),
'sticky' => $pinned
- );
+ ];
if (! $this->isLegacy) {
$bookmark = new Bookmark();
$this->bookmarks[$id] = $bookmark->fromArray($link);
@@ -184,10 +187,10 @@ class ReferenceLinkDB
}
if ($private) {
- $this->_privateCount++;
+ $this->privateCount++;
return;
}
- $this->_publicCount++;
+ $this->publicCount++;
}
/**
@@ -198,7 +201,7 @@ class ReferenceLinkDB
$this->reorder();
file_put_contents(
$filename,
- 'bookmarks))).' */ ?>'
+ 'bookmarks))) . ' */ ?>'
);
}
@@ -233,7 +236,7 @@ class ReferenceLinkDB
*/
public function countLinks()
{
- return $this->_publicCount + $this->_privateCount;
+ return $this->publicCount + $this->privateCount;
}
/**
@@ -241,7 +244,7 @@ class ReferenceLinkDB
*/
public function countPublicLinks()
{
- return $this->_publicCount;
+ return $this->publicCount;
}
/**
@@ -249,7 +252,7 @@ class ReferenceLinkDB
*/
public function countPrivateLinks()
{
- return $this->_privateCount;
+ return $this->privateCount;
}
/**
diff --git a/tests/utils/ReferenceSessionIdHashes.php b/tests/utils/ReferenceSessionIdHashes.php
index 60b1c007..d0b2ddf7 100644
--- a/tests/utils/ReferenceSessionIdHashes.php
+++ b/tests/utils/ReferenceSessionIdHashes.php
@@ -1,4 +1,7 @@