Coding style: Apply automatic PHPCBF to tests forlder (PSR12)
Related to #95
This commit is contained in:
parent
e1847ae5a7
commit
0681511699
85 changed files with 560 additions and 499 deletions
|
@ -5,7 +5,7 @@
|
|||
<file>index.php</file>
|
||||
<file>application</file>
|
||||
<file>plugins</file>
|
||||
<!-- <file>tests</file>-->
|
||||
<file>tests</file>
|
||||
|
||||
<exclude-pattern>*/*.css</exclude-pattern>
|
||||
<exclude-pattern>*/*.js</exclude-pattern>
|
||||
|
|
|
@ -39,7 +39,7 @@ public function setUp(): void
|
|||
public function testPlugin(): void
|
||||
{
|
||||
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
||||
$this->pluginManager->load(array(self::$pluginName));
|
||||
$this->pluginManager->load([self::$pluginName]);
|
||||
|
||||
$this->assertTrue(function_exists('hook_test_random'));
|
||||
|
||||
|
@ -50,19 +50,19 @@ public function testPlugin(): void
|
|||
static::assertSame('woot', $data[1]);
|
||||
|
||||
$data = [0 => 'woot'];
|
||||
$this->pluginManager->executeHooks('random', $data, array('target' => 'test'));
|
||||
$this->pluginManager->executeHooks('random', $data, ['target' => 'test']);
|
||||
|
||||
static::assertCount(2, $data);
|
||||
static::assertSame('page test', $data[1]);
|
||||
|
||||
$data = [0 => 'woot'];
|
||||
$this->pluginManager->executeHooks('random', $data, array('loggedin' => true));
|
||||
$this->pluginManager->executeHooks('random', $data, ['loggedin' => true]);
|
||||
|
||||
static::assertCount(2, $data);
|
||||
static::assertEquals('loggedin', $data[1]);
|
||||
|
||||
$data = [0 => 'woot'];
|
||||
$this->pluginManager->executeHooks('random', $data, array('loggedin' => null));
|
||||
$this->pluginManager->executeHooks('random', $data, ['loggedin' => null]);
|
||||
|
||||
static::assertCount(3, $data);
|
||||
static::assertEquals('loggedin', $data[1]);
|
||||
|
@ -76,7 +76,7 @@ public function testPlugin(): void
|
|||
public function testPluginWithPhpError(): void
|
||||
{
|
||||
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
||||
$this->pluginManager->load(array(self::$pluginName));
|
||||
$this->pluginManager->load([self::$pluginName]);
|
||||
|
||||
$this->assertTrue(function_exists('hook_test_error'));
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* TimeZone's tests
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Utilities' tests
|
||||
*/
|
||||
|
@ -187,7 +188,7 @@ public function testGenerateLocation()
|
|||
public function testGenerateLocationLoop()
|
||||
{
|
||||
$ref = 'http://localhost/?test';
|
||||
$this->assertEquals('./?', generateLocation($ref, 'localhost', array('test')));
|
||||
$this->assertEquals('./?', generateLocation($ref, 'localhost', ['test']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
@ -106,7 +107,7 @@ public function testGetInfo()
|
|||
$title = 'My bookmarks';
|
||||
$headerLink = 'http://shaarli.tld';
|
||||
$timezone = 'Europe/Paris';
|
||||
$enabledPlugins = array('foo', 'bar');
|
||||
$enabledPlugins = ['foo', 'bar'];
|
||||
$defaultPrivateLinks = true;
|
||||
$this->conf->set('general.title', $title);
|
||||
$this->conf->set('general.header_link', $headerLink);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use malkusch\lock\mutex\NoMutex;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Link datastore tests
|
||||
*/
|
||||
|
|
|
@ -417,28 +417,28 @@ public function testFilterCrossedSearch()
|
|||
1,
|
||||
count(self::$linkFilter->filter(
|
||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||
array($tags, $terms)
|
||||
[$tags, $terms]
|
||||
))
|
||||
);
|
||||
$this->assertEquals(
|
||||
2,
|
||||
count(self::$linkFilter->filter(
|
||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||
array('', $terms)
|
||||
['', $terms]
|
||||
))
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
count(self::$linkFilter->filter(
|
||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||
array(false, 'PSR-2')
|
||||
[false, 'PSR-2']
|
||||
))
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
count(self::$linkFilter->filter(
|
||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||
array($tags, '')
|
||||
[$tags, '']
|
||||
))
|
||||
);
|
||||
$this->assertEquals(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
|
@ -29,13 +30,13 @@ public function testSetGet()
|
|||
$this->conf->set('paramInt', 42);
|
||||
$this->conf->set('paramString', 'value1');
|
||||
$this->conf->set('paramBool', false);
|
||||
$this->conf->set('paramArray', array('foo' => 'bar'));
|
||||
$this->conf->set('paramArray', ['foo' => 'bar']);
|
||||
$this->conf->set('paramNull', null);
|
||||
|
||||
$this->assertEquals(42, $this->conf->get('paramInt'));
|
||||
$this->assertEquals('value1', $this->conf->get('paramString'));
|
||||
$this->assertFalse($this->conf->get('paramBool'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $this->conf->get('paramArray'));
|
||||
$this->assertEquals(['foo' => 'bar'], $this->conf->get('paramArray'));
|
||||
$this->assertEquals(null, $this->conf->get('paramNull'));
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ public function testSetWriteGet()
|
|||
$this->conf->set('paramInt', 42);
|
||||
$this->conf->set('paramString', 'value1');
|
||||
$this->conf->set('paramBool', false);
|
||||
$this->conf->set('paramArray', array('foo' => 'bar'));
|
||||
$this->conf->set('paramArray', ['foo' => 'bar']);
|
||||
$this->conf->set('paramNull', null);
|
||||
|
||||
$this->conf->setConfigFile('tests/utils/config/configTmp');
|
||||
|
@ -62,7 +63,7 @@ public function testSetWriteGet()
|
|||
$this->assertEquals(42, $this->conf->get('paramInt'));
|
||||
$this->assertEquals('value1', $this->conf->get('paramString'));
|
||||
$this->assertFalse($this->conf->get('paramBool'));
|
||||
$this->assertEquals(array('foo' => 'bar'), $this->conf->get('paramArray'));
|
||||
$this->assertEquals(['foo' => 'bar'], $this->conf->get('paramArray'));
|
||||
$this->assertEquals(null, $this->conf->get('paramNull'));
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ public function testSetArrayKey()
|
|||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
|
||||
|
||||
$this->conf->set(array('foo' => 'bar'), 'stuff');
|
||||
$this->conf->set(['foo' => 'bar'], 'stuff');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Config;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,7 @@ public function testRead()
|
|||
*/
|
||||
public function testReadNonExistent()
|
||||
{
|
||||
$this->assertEquals(array(), $this->configIO->read('nope'));
|
||||
$this->assertEquals([], $this->configIO->read('nope'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,16 +61,16 @@ public function testReadEmpty()
|
|||
public function testWriteNew()
|
||||
{
|
||||
$dataFile = 'tests/utils/config/configWrite.php';
|
||||
$data = array(
|
||||
$data = [
|
||||
'login' => 'root',
|
||||
'redirector' => 'lala',
|
||||
'config' => array(
|
||||
'config' => [
|
||||
'DATASTORE' => 'data/datastore.php',
|
||||
),
|
||||
'plugins' => array(
|
||||
],
|
||||
'plugins' => [
|
||||
'WALLABAG_VERSION' => '1',
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$this->configIO->write($dataFile, $data);
|
||||
$expected = '<?php
|
||||
$GLOBALS[\'login\'] = \'root\';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Config;
|
||||
|
||||
use Shaarli\Config\Exception\PluginConfigOrderException;
|
||||
|
@ -35,12 +36,16 @@ public function testSavePluginConfigValid()
|
|||
|
||||
mkdir($path = __DIR__ . '/folder');
|
||||
PluginManager::$PLUGINS_PATH = $path;
|
||||
array_map(function (string $plugin) use ($path) { touch($path . '/' . $plugin); }, $expected);
|
||||
array_map(function (string $plugin) use ($path) {
|
||||
touch($path . '/' . $plugin);
|
||||
}, $expected);
|
||||
|
||||
$out = save_plugin_config($data);
|
||||
$this->assertEquals($expected, $out);
|
||||
|
||||
array_map(function (string $plugin) use ($path) { unlink($path . '/' . $plugin); }, $expected);
|
||||
array_map(function (string $plugin) use ($path) {
|
||||
unlink($path . '/' . $plugin);
|
||||
}, $expected);
|
||||
rmdir($path);
|
||||
}
|
||||
|
||||
|
@ -51,13 +56,13 @@ public function testSavePluginConfigInvalid()
|
|||
{
|
||||
$this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class);
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'plugin2' => 0,
|
||||
'plugin3' => 0,
|
||||
'order_plugin3' => 0,
|
||||
'plugin4' => 0,
|
||||
'order_plugin4' => 0,
|
||||
);
|
||||
];
|
||||
|
||||
save_plugin_config($data);
|
||||
}
|
||||
|
@ -67,7 +72,7 @@ public function testSavePluginConfigInvalid()
|
|||
*/
|
||||
public function testSavePluginConfigEmpty()
|
||||
{
|
||||
$this->assertEquals(array(), save_plugin_config(array()));
|
||||
$this->assertEquals([], save_plugin_config([]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,14 +80,14 @@ public function testSavePluginConfigEmpty()
|
|||
*/
|
||||
public function testValidatePluginOrderValid()
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'order_plugin1' => 2,
|
||||
'plugin2' => 0,
|
||||
'plugin3' => 0,
|
||||
'order_plugin3' => 1,
|
||||
'plugin4' => 0,
|
||||
'order_plugin4' => 5,
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertTrue(validate_plugin_order($data));
|
||||
}
|
||||
|
@ -92,11 +97,11 @@ public function testValidatePluginOrderValid()
|
|||
*/
|
||||
public function testValidatePluginOrderInvalid()
|
||||
{
|
||||
$data = array(
|
||||
$data = [
|
||||
'order_plugin1' => 2,
|
||||
'order_plugin3' => 1,
|
||||
'order_plugin4' => 1,
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertFalse(validate_plugin_order($data));
|
||||
}
|
||||
|
@ -106,20 +111,20 @@ public function testValidatePluginOrderInvalid()
|
|||
*/
|
||||
public function testLoadPluginParameterValues()
|
||||
{
|
||||
$plugins = array(
|
||||
'plugin_name' => array(
|
||||
'parameters' => array(
|
||||
'param1' => array('value' => true),
|
||||
'param2' => array('value' => false),
|
||||
'param3' => array('value' => ''),
|
||||
)
|
||||
)
|
||||
);
|
||||
$plugins = [
|
||||
'plugin_name' => [
|
||||
'parameters' => [
|
||||
'param1' => ['value' => true],
|
||||
'param2' => ['value' => false],
|
||||
'param3' => ['value' => ''],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$parameters = array(
|
||||
$parameters = [
|
||||
'param1' => 'value1',
|
||||
'param2' => 'value2',
|
||||
);
|
||||
];
|
||||
|
||||
$result = load_plugin_parameter_values($plugins, $parameters);
|
||||
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PageCache tests
|
||||
*/
|
||||
|
||||
namespace Shaarli\Feed;
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,13 +66,13 @@ public static function setUpBeforeClass(): void
|
|||
true
|
||||
);
|
||||
|
||||
self::$serverInfo = array(
|
||||
self::$serverInfo = [
|
||||
'HTTPS' => 'Off',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '80',
|
||||
'SCRIPT_NAME' => '/index.php',
|
||||
'REQUEST_URI' => '/feed/atom',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,10 +149,10 @@ public function testAtomBuildData()
|
|||
*/
|
||||
public function testBuildDataFiltered()
|
||||
{
|
||||
$criteria = array(
|
||||
$criteria = [
|
||||
'searchtags' => 'stuff',
|
||||
'searchterm' => 'beard',
|
||||
);
|
||||
];
|
||||
$feedBuilder = new FeedBuilder(
|
||||
self::$bookmarkService,
|
||||
self::$formatter,
|
||||
|
@ -172,9 +172,9 @@ public function testBuildDataFiltered()
|
|||
*/
|
||||
public function testBuildDataCount()
|
||||
{
|
||||
$criteria = array(
|
||||
$criteria = [
|
||||
'nb' => '3',
|
||||
);
|
||||
];
|
||||
$feedBuilder = new FeedBuilder(
|
||||
self::$bookmarkService,
|
||||
self::$formatter,
|
||||
|
@ -259,13 +259,13 @@ public function testBuildDataHideDates()
|
|||
*/
|
||||
public function testBuildDataServerSubdir()
|
||||
{
|
||||
$serverInfo = array(
|
||||
$serverInfo = [
|
||||
'HTTPS' => 'Off',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '8080',
|
||||
'SCRIPT_NAME' => '/~user/shaarli/index.php',
|
||||
'REQUEST_URI' => '/~user/shaarli/feed/atom',
|
||||
);
|
||||
];
|
||||
$feedBuilder = new FeedBuilder(
|
||||
self::$bookmarkService,
|
||||
self::$formatter,
|
||||
|
|
|
@ -63,7 +63,8 @@ public function testMiddlewareWhileLoggedOut(): void
|
|||
$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(
|
||||
|
|
|
@ -91,7 +91,7 @@ public function testMiddlewareExecutionWithFrontException(): void
|
|||
$controller = function (): void {
|
||||
$exception = new LoginBannedException();
|
||||
|
||||
throw new $exception;
|
||||
throw new $exception();
|
||||
};
|
||||
|
||||
$pageBuilder = $this->createMock(PageBuilder::class);
|
||||
|
@ -148,7 +148,8 @@ public function testMiddlewareExecutionWithServerException(): void
|
|||
return $uri;
|
||||
});
|
||||
|
||||
$dummyException = new class() extends \Exception {};
|
||||
$dummyException = new class () extends \Exception {
|
||||
};
|
||||
|
||||
$response = new Response();
|
||||
$controller = function () use ($dummyException): void {
|
||||
|
|
|
@ -122,8 +122,7 @@ public function testSaveNewConfig(): void
|
|||
}
|
||||
|
||||
return $parameters[$key];
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$response = new Response();
|
||||
|
||||
|
@ -137,8 +136,7 @@ public function testSaveNewConfig(): void
|
|||
}
|
||||
|
||||
static::assertSame($parametersConfigMapping[$key], $value);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$result = $this->controller->save($request, $response);
|
||||
static::assertSame(302, $result->getStatusCode());
|
||||
|
|
|
@ -80,7 +80,10 @@ function (
|
|||
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);
|
||||
|
|
|
@ -74,7 +74,10 @@ public function testImportDefault(): void
|
|||
function (
|
||||
array $post,
|
||||
UploadedFileInterface $file
|
||||
) use ($parameters, $requestFile): string {
|
||||
) use (
|
||||
$parameters,
|
||||
$requestFile
|
||||
): string {
|
||||
static::assertSame($parameters, $post);
|
||||
static::assertSame($requestFile, $file);
|
||||
|
||||
|
|
|
@ -29,13 +29,17 @@ public function setUp(): void
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -365,5 +365,4 @@ public function testSaveBookmarkWrongToken(): void
|
|||
|
||||
$this->controller->save($request, $response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,8 +54,7 @@ public function testIndexDefaultFirstPage(): void
|
|||
(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')
|
||||
|
|
|
@ -285,7 +285,9 @@ public function testValidIndexControllerInvokeHeightAdjustment(): void
|
|||
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 @@ public function testValidRssControllerInvokeDefault(): void
|
|||
$cachedPage->expects(static::once())->method('cache')->with('dailyrss');
|
||||
|
||||
return $cachedPage;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Save RainTPL assigned variables
|
||||
$assignedVariables = [];
|
||||
|
|
|
@ -41,7 +41,8 @@ public function testDisplayFrontExceptionError(): void
|
|||
$result = ($this->controller)(
|
||||
$request,
|
||||
$response,
|
||||
new class($message, $errorCode) extends ShaarliFrontException {}
|
||||
new class ($message, $errorCode) extends ShaarliFrontException {
|
||||
}
|
||||
);
|
||||
|
||||
static::assertSame($errorCode, $result->getStatusCode());
|
||||
|
|
|
@ -118,5 +118,5 @@ protected static function generateString(int $length): string
|
|||
/**
|
||||
* Force to be used in PHPUnit context.
|
||||
*/
|
||||
protected abstract function isInTestsContext(): bool;
|
||||
abstract protected function isInTestsContext(): bool;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Helper;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
@ -301,7 +302,7 @@ public function testCheckCurrentResourcePermissions()
|
|||
$conf->set('resource.update_check', 'data/lastupdatecheck.txt');
|
||||
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
[],
|
||||
ApplicationUtils::checkResourcePermissions($conf)
|
||||
);
|
||||
}
|
||||
|
@ -324,7 +325,7 @@ public function testCheckCurrentResourcePermissionsErrors()
|
|||
$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 +336,7 @@ public function testCheckCurrentResourcePermissionsErrors()
|
|||
'"null/pagecache" directory is not writable',
|
||||
'"null/tmp" directory is not readable',
|
||||
'"null/tmp" directory is not writable'
|
||||
),
|
||||
],
|
||||
ApplicationUtils::checkResourcePermissions($conf)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -147,7 +147,8 @@ public function getDescriptionByTypeExceptionUnknownType(): void
|
|||
/**
|
||||
* @dataProvider getRssLengthsByType
|
||||
*/
|
||||
public function testGeRssLengthsByType(string $type): void {
|
||||
public function testGeRssLengthsByType(string $type): void
|
||||
{
|
||||
$length = DailyPageHelper::getRssLengthByType($type);
|
||||
|
||||
static::assertIsInt($length);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* HttpUtils' tests
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* HttpUtils' tests
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
|||
*/
|
||||
public function testWithoutProxy()
|
||||
{
|
||||
$this->assertFalse(getIpAddressFromProxy(array(), array()));
|
||||
$this->assertFalse(getIpAddressFromProxy([], []));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,8 +24,8 @@ public function testWithoutProxy()
|
|||
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 +36,11 @@ public function testWithMultipleForwardedIp()
|
|||
$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 +51,11 @@ public function testWithTrustedIp()
|
|||
$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]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* HttpUtils' tests
|
||||
*/
|
||||
|
@ -22,24 +23,24 @@ public function testRemoveIndex()
|
|||
$this->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 +53,24 @@ public function testOtherResource()
|
|||
$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 +83,26 @@ public function testPageUrlWithRoute()
|
|||
$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 +115,26 @@ public function testPageUrlWithRouteUnderSubfolder()
|
|||
$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',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,26 +25,26 @@ public function testIndexUrlWithConstantDefined()
|
|||
$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',
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* HttpUtils' tests
|
||||
*/
|
||||
|
@ -20,26 +21,26 @@ public function testRemoveIndex()
|
|||
$this->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 +53,26 @@ public function testOtherResource()
|
|||
$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'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* HttpUtils' tests
|
||||
*/
|
||||
|
@ -20,22 +21,22 @@ public function testHttpsScheme()
|
|||
$this->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 +49,22 @@ public function testHttpsProxyForwardedHost()
|
|||
$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 +77,51 @@ public function testHttpsProxyForward()
|
|||
$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 +135,11 @@ public function testPort()
|
|||
$this->assertEquals(
|
||||
'http://host.tld:8080',
|
||||
server_url(
|
||||
array(
|
||||
[
|
||||
'HTTPS' => 'OFF',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '8080'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -146,11 +147,11 @@ public function testPort()
|
|||
$this->assertEquals(
|
||||
'https://host.tld:8080',
|
||||
server_url(
|
||||
array(
|
||||
[
|
||||
'HTTPS' => 'ON',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '8080'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -163,11 +164,11 @@ public function testStandardHttpPort()
|
|||
$this->assertEquals(
|
||||
'http://host.tld',
|
||||
server_url(
|
||||
array(
|
||||
[
|
||||
'HTTPS' => 'OFF',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '80'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -180,11 +181,11 @@ public function testStandardHttpsPort()
|
|||
$this->assertEquals(
|
||||
'https://host.tld',
|
||||
server_url(
|
||||
array(
|
||||
[
|
||||
'HTTPS' => 'ON',
|
||||
'SERVER_NAME' => 'host.tld',
|
||||
'SERVER_PORT' => '443'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -197,26 +198,26 @@ public function testHttpWithPort433()
|
|||
$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'
|
||||
)
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,12 @@ function (&$charset) use (
|
|||
->expects(static::once())
|
||||
->method('getCurlDownloadCallback')
|
||||
->willReturnCallback(
|
||||
function (&$charset, &$title, &$description, &$tags) use (
|
||||
function (
|
||||
&$charset,
|
||||
&$title,
|
||||
&$description,
|
||||
&$tags
|
||||
) use (
|
||||
$remoteCharset,
|
||||
$remoteTitle,
|
||||
$remoteDesc,
|
||||
|
@ -124,7 +129,8 @@ public function testEmptyRetrieval(): void
|
|||
->method('getCurlDownloadCallback')
|
||||
->willReturnCallback(
|
||||
function (): callable {
|
||||
return function (): void {};
|
||||
return function (): void {
|
||||
};
|
||||
}
|
||||
)
|
||||
;
|
||||
|
@ -133,7 +139,8 @@ function (): callable {
|
|||
->method('getCurlHeaderCallback')
|
||||
->willReturnCallback(
|
||||
function (): callable {
|
||||
return function (): void {};
|
||||
return function (): void {
|
||||
};
|
||||
}
|
||||
)
|
||||
;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* UrlUtils's tests
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Unitary tests for cleanup_url()
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Unitary tests for get_url_scheme()
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Unpares UrlUtils's tests
|
||||
*/
|
||||
|
@ -17,7 +18,7 @@ class UnparseUrlTest extends \Shaarli\TestCase
|
|||
*/
|
||||
public function testUnparseEmptyArray()
|
||||
{
|
||||
$this->assertEquals('', unparse_url(array()));
|
||||
$this->assertEquals('', unparse_url([]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once 'tests/bootstrap.php';
|
||||
|
||||
if (! empty(getenv('UT_LOCALE'))) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Shaarli;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Updater;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Link datastore tests
|
||||
*/
|
||||
|
@ -118,7 +119,7 @@ public function testCheckDBNew()
|
|||
$this->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 +136,7 @@ public function testCheckDBLoad()
|
|||
$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 +186,7 @@ public function testSave()
|
|||
$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 +194,7 @@ public function testSave()
|
|||
'private' => 0,
|
||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150518_190000'),
|
||||
'tags' => 'unit test'
|
||||
);
|
||||
];
|
||||
$testDB[$link['id']] = $link;
|
||||
$testDB->save('tests');
|
||||
|
||||
|
@ -239,12 +240,12 @@ public function testCountHiddenPublic()
|
|||
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 +281,7 @@ public function testGetUnknownLinkFromURL()
|
|||
public function testAllTags()
|
||||
{
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'web' => 3,
|
||||
'cartoon' => 2,
|
||||
'gnu' => 2,
|
||||
|
@ -300,12 +301,12 @@ public function testAllTags()
|
|||
'coding-style' => 1,
|
||||
'quality' => 1,
|
||||
'standards' => 1,
|
||||
),
|
||||
],
|
||||
self::$publicLinkDB->linksCountPerTag()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'web' => 4,
|
||||
'cartoon' => 3,
|
||||
'gnu' => 2,
|
||||
|
@ -332,11 +333,11 @@ public function testAllTags()
|
|||
'coding-style' => 1,
|
||||
'quality' => 1,
|
||||
'standards' => 1,
|
||||
),
|
||||
],
|
||||
self::$privateLinkDB->linksCountPerTag()
|
||||
);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
[
|
||||
'web' => 4,
|
||||
'cartoon' => 2,
|
||||
'gnu' => 1,
|
||||
|
@ -349,17 +350,17 @@ public function testAllTags()
|
|||
'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 +371,7 @@ public function testAllTags()
|
|||
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 +383,8 @@ public function testFilterString()
|
|||
*/
|
||||
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 +398,7 @@ public function testFilterArray()
|
|||
public function testHiddenTags()
|
||||
{
|
||||
$tags = '.hidden';
|
||||
$request = array('searchtags' => $tags);
|
||||
$request = ['searchtags' => $tags];
|
||||
$this->assertEquals(
|
||||
1,
|
||||
count(self::$privateLinkDB->filterSearch($request, true, false))
|
||||
|
|
|
@ -450,28 +450,28 @@ public function testFilterCrossedSearch()
|
|||
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(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Updater;
|
||||
|
||||
use DateTime;
|
||||
|
@ -51,10 +52,10 @@ protected function setUp(): void
|
|||
*/
|
||||
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 +65,7 @@ public function testReadEmptyUpdatesFile()
|
|||
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 +87,7 @@ public function testWriteEmptyUpdatesFile()
|
|||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
||||
|
||||
UpdaterUtils::writeUpdatesFile('', array('test'));
|
||||
UpdaterUtils::writeUpdatesFile('', ['test']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +102,7 @@ public function testWriteUpdatesFileNotWritable()
|
|||
touch($updatesFile);
|
||||
chmod($updatesFile, 0444);
|
||||
try {
|
||||
@UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
|
||||
@UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
|
||||
} catch (Exception $e) {
|
||||
unlink($updatesFile);
|
||||
throw $e;
|
||||
|
@ -115,17 +116,17 @@ public function testWriteUpdatesFileNotWritable()
|
|||
*/
|
||||
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 +134,13 @@ public function testNoUpdates()
|
|||
*/
|
||||
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 +149,14 @@ public function testUpdatesFirstTime()
|
|||
*/
|
||||
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 +167,13 @@ public function testUpdateFailed()
|
|||
{
|
||||
$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 +198,7 @@ public function testUpdateMergeDeprecatedConfig()
|
|||
$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 +215,7 @@ public function testUpdateMergeDeprecatedConfig()
|
|||
*/
|
||||
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'));
|
||||
|
@ -229,10 +230,10 @@ public function testRenameDashTags()
|
|||
$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 +248,7 @@ public function testConfigToJson()
|
|||
// 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 +273,7 @@ public function testConfigToJson()
|
|||
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 +292,7 @@ public function testEscapeConfig()
|
|||
$headerLink = '<script>alert("header_link");</script>';
|
||||
$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();
|
||||
|
@ -308,7 +309,7 @@ public function testUpdateApiSettings()
|
|||
$confFile = 'sandbox/config';
|
||||
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'));
|
||||
|
@ -329,7 +330,7 @@ public function testUpdateApiSettingsNothingToDo()
|
|||
$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'));
|
||||
|
@ -341,8 +342,8 @@ public function testUpdateApiSettingsNothingToDo()
|
|||
*/
|
||||
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,24 +351,24 @@ public function testDatastoreIds()
|
|||
'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->setLinks($links);
|
||||
$refDB->write(self::$testDatastore);
|
||||
|
@ -378,7 +379,7 @@ public function testDatastoreIds()
|
|||
$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);
|
||||
|
@ -445,7 +446,7 @@ public function testDatastoreIdsNothingToDo()
|
|||
$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));
|
||||
}
|
||||
|
@ -786,7 +787,7 @@ public function testUpdateStickyValid()
|
|||
$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);
|
||||
|
@ -817,7 +818,7 @@ public function testUpdateStickyNothingToDo()
|
|||
$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);
|
||||
|
|
|
@ -365,7 +365,7 @@ public function testImportDefaultPrivacyNoPost()
|
|||
*/
|
||||
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:'
|
||||
|
@ -408,7 +408,7 @@ public function testImportKeepPrivacy()
|
|||
*/
|
||||
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:'
|
||||
|
@ -426,7 +426,7 @@ public function testImportAsPublic()
|
|||
*/
|
||||
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:'
|
||||
|
@ -447,7 +447,7 @@ public function testOverwriteAsPublic()
|
|||
$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.',
|
||||
|
@ -459,10 +459,10 @@ public function testOverwriteAsPublic()
|
|||
$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.',
|
||||
|
@ -482,7 +482,7 @@ public function testOverwriteAsPrivate()
|
|||
$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.',
|
||||
|
@ -494,10 +494,10 @@ public function testOverwriteAsPrivate()
|
|||
$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.',
|
||||
|
@ -514,7 +514,7 @@ public function testOverwriteAsPrivate()
|
|||
*/
|
||||
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:'
|
||||
|
@ -525,7 +525,7 @@ public function testSkipOverwrite()
|
|||
$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.',
|
||||
|
@ -540,10 +540,10 @@ public function testSkipOverwrite()
|
|||
*/
|
||||
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:'
|
||||
|
@ -561,10 +561,10 @@ public function testSetDefaultTags()
|
|||
*/
|
||||
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:'
|
||||
|
@ -631,7 +631,7 @@ public function testImportSameDate()
|
|||
$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)
|
||||
$this->netscapeBookmarkUtils->import([], $files)
|
||||
);
|
||||
$this->assertEquals(3, $this->bookmarkService->count());
|
||||
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Addlink;
|
||||
|
||||
use Shaarli\Plugin\PluginManager;
|
||||
|
@ -25,7 +26,7 @@ protected function setUp(): void
|
|||
public function testAddlinkHeaderLoggedIn()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data = [$str => $str];
|
||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||
$data['_LOGGEDIN_'] = true;
|
||||
$data['_BASE_PATH_'] = '/subfolder';
|
||||
|
@ -34,7 +35,7 @@ public function testAddlinkHeaderLoggedIn()
|
|||
$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 @@ public function testAddlinkHeaderLoggedIn()
|
|||
public function testAddlinkHeaderLoggedOut()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $str);
|
||||
$data = [$str => $str];
|
||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||
$data['_LOGGEDIN_'] = false;
|
||||
$data['_BASE_PATH_'] = '/subfolder';
|
||||
|
|
|
@ -47,16 +47,16 @@ public function testArchiveorgLinklistOnExternalLinks(): void
|
|||
{
|
||||
$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 +84,41 @@ public function testArchiveorgLinklistOnInternalLinks(): void
|
|||
$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);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Isso;
|
||||
|
||||
use DateTime;
|
||||
|
@ -55,16 +56,16 @@ public function testIssoDisplayed(): void
|
|||
|
||||
$str = 'http://randomstr.com/test';
|
||||
$date = '20161118_100001';
|
||||
$data = array(
|
||||
$data = [
|
||||
'title' => $str,
|
||||
'links' => array(
|
||||
array(
|
||||
'links' => [
|
||||
[
|
||||
'id' => 12,
|
||||
'url' => $str,
|
||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$data = hook_isso_render_linklist($data, $conf);
|
||||
|
||||
|
@ -96,23 +97,23 @@ public function testIssoMultipleLinks(): void
|
|||
$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
|
||||
|
@ -130,18 +131,18 @@ public function testIssoNotDisplayedWhenSearch(): void
|
|||
|
||||
$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);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Playvideos;
|
||||
|
||||
/**
|
||||
|
@ -30,14 +31,14 @@ protected function setUp(): void
|
|||
public function testPlayvideosHeader()
|
||||
{
|
||||
$str = 'stuff';
|
||||
$data = array($str => $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 +50,14 @@ public function testPlayvideosHeader()
|
|||
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);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Pubsubhubbub;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Qrcode;
|
||||
|
||||
/**
|
||||
|
@ -30,14 +31,14 @@ protected function setUp(): void
|
|||
public function testQrcodeLinklist()
|
||||
{
|
||||
$str = 'http://randomstr.com/test';
|
||||
$data = array(
|
||||
$data = [
|
||||
'title' => $str,
|
||||
'links' => array(
|
||||
array(
|
||||
'links' => [
|
||||
[
|
||||
'url' => $str,
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$data = hook_qrcode_render_linklist($data);
|
||||
$link = $data['links'][0];
|
||||
|
@ -56,14 +57,14 @@ public function testQrcodeLinklist()
|
|||
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);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Wallabag;
|
||||
|
||||
use Shaarli\Config\ConfigManager;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Plugin\Wallabag;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ class PageCacheManagerTest extends TestCase
|
|||
protected static $testCacheDir = 'sandbox/dummycache';
|
||||
|
||||
// dummy cached file names / content
|
||||
protected static $pages = array('a', 'toto', 'd7b59c');
|
||||
protected static $pages = ['a', 'toto', 'd7b59c'];
|
||||
|
||||
/** @var PageCacheManager */
|
||||
protected $cacheManager;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Shaarli\Security;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
|
@ -349,7 +349,11 @@ public function testCheckCredentialsFromLdapWrongLoginAndPassword()
|
|||
{
|
||||
$this->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 @@ public function testCheckCredentialsFromLdapGoodLoginAndPassword()
|
|||
{
|
||||
$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;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Updater;
|
||||
|
||||
use Exception;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Shaarli\Updater;
|
||||
|
||||
use Exception;
|
||||
|
@ -10,7 +11,6 @@
|
|||
use Shaarli\Plugin\PluginManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Class UpdaterTest.
|
||||
* Runs unit tests against the updater class.
|
||||
|
@ -67,10 +67,10 @@ protected function setUp(): void
|
|||
*/
|
||||
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 +80,7 @@ public function testReadEmptyUpdatesFile()
|
|||
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 +102,7 @@ public function testWriteEmptyUpdatesFile()
|
|||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
||||
|
||||
UpdaterUtils::writeUpdatesFile('', array('test'));
|
||||
UpdaterUtils::writeUpdatesFile('', ['test']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ public function testWriteUpdatesFileNotWritable()
|
|||
touch($updatesFile);
|
||||
chmod($updatesFile, 0444);
|
||||
try {
|
||||
@UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
|
||||
@UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
|
||||
} catch (Exception $e) {
|
||||
unlink($updatesFile);
|
||||
throw $e;
|
||||
|
@ -131,17 +131,17 @@ public function testWriteUpdatesFileNotWritable()
|
|||
*/
|
||||
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 +149,13 @@ public function testNoUpdates()
|
|||
*/
|
||||
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 +164,14 @@ public function testUpdatesFirstTime()
|
|||
*/
|
||||
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 +182,13 @@ public function testUpdateFailed()
|
|||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Old-style mock for cURL, as PHPUnit doesn't allow to mock global functions
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
use Shaarli\Bookmark\BookmarkArray;
|
||||
use Shaarli\Bookmark\BookmarkFilter;
|
||||
use Shaarli\Bookmark\BookmarkIO;
|
||||
|
|
|
@ -10,7 +10,7 @@ class ReferenceLinkDB
|
|||
{
|
||||
public static $NB_LINKS_TOTAL = 11;
|
||||
|
||||
private $bookmarks = array();
|
||||
private $bookmarks = [];
|
||||
private $_publicCount = 0;
|
||||
private $_privateCount = 0;
|
||||
|
||||
|
@ -164,7 +164,7 @@ protected function addLink(
|
|||
$shorturl = '',
|
||||
$pinned = false
|
||||
) {
|
||||
$link = array(
|
||||
$link = [
|
||||
'id' => $id,
|
||||
'title' => $title,
|
||||
'url' => $url,
|
||||
|
@ -175,7 +175,7 @@ protected function addLink(
|
|||
'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);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Testing the untestable - Session ID generation
|
||||
*/
|
||||
|
@ -13,9 +14,9 @@ class ReferenceSessionIdHashes
|
|||
public static function genAllHashes()
|
||||
{
|
||||
foreach (hash_algos() as $algo) {
|
||||
self::$sidHashes[$algo] = array();
|
||||
self::$sidHashes[$algo] = [];
|
||||
|
||||
foreach (array(4, 5, 6) as $bpc) {
|
||||
foreach ([4, 5, 6] as $bpc) {
|
||||
self::$sidHashes[$algo][$bpc] = self::genSidHash($algo, $bpc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$GLOBALS['login'] = 'root';
|
||||
$GLOBALS['hash'] = 'hash';
|
||||
$GLOBALS['salt'] = 'salt';
|
||||
|
|
Loading…
Reference in a new issue