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>index.php</file>
|
||||||
<file>application</file>
|
<file>application</file>
|
||||||
<file>plugins</file>
|
<file>plugins</file>
|
||||||
<!-- <file>tests</file>-->
|
<file>tests</file>
|
||||||
|
|
||||||
<exclude-pattern>*/*.css</exclude-pattern>
|
<exclude-pattern>*/*.css</exclude-pattern>
|
||||||
<exclude-pattern>*/*.js</exclude-pattern>
|
<exclude-pattern>*/*.js</exclude-pattern>
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PluginManagerTest extends \Shaarli\TestCase
|
||||||
public function testPlugin(): void
|
public function testPlugin(): void
|
||||||
{
|
{
|
||||||
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
||||||
$this->pluginManager->load(array(self::$pluginName));
|
$this->pluginManager->load([self::$pluginName]);
|
||||||
|
|
||||||
$this->assertTrue(function_exists('hook_test_random'));
|
$this->assertTrue(function_exists('hook_test_random'));
|
||||||
|
|
||||||
|
@ -50,19 +50,19 @@ class PluginManagerTest extends \Shaarli\TestCase
|
||||||
static::assertSame('woot', $data[1]);
|
static::assertSame('woot', $data[1]);
|
||||||
|
|
||||||
$data = [0 => 'woot'];
|
$data = [0 => 'woot'];
|
||||||
$this->pluginManager->executeHooks('random', $data, array('target' => 'test'));
|
$this->pluginManager->executeHooks('random', $data, ['target' => 'test']);
|
||||||
|
|
||||||
static::assertCount(2, $data);
|
static::assertCount(2, $data);
|
||||||
static::assertSame('page test', $data[1]);
|
static::assertSame('page test', $data[1]);
|
||||||
|
|
||||||
$data = [0 => 'woot'];
|
$data = [0 => 'woot'];
|
||||||
$this->pluginManager->executeHooks('random', $data, array('loggedin' => true));
|
$this->pluginManager->executeHooks('random', $data, ['loggedin' => true]);
|
||||||
|
|
||||||
static::assertCount(2, $data);
|
static::assertCount(2, $data);
|
||||||
static::assertEquals('loggedin', $data[1]);
|
static::assertEquals('loggedin', $data[1]);
|
||||||
|
|
||||||
$data = [0 => 'woot'];
|
$data = [0 => 'woot'];
|
||||||
$this->pluginManager->executeHooks('random', $data, array('loggedin' => null));
|
$this->pluginManager->executeHooks('random', $data, ['loggedin' => null]);
|
||||||
|
|
||||||
static::assertCount(3, $data);
|
static::assertCount(3, $data);
|
||||||
static::assertEquals('loggedin', $data[1]);
|
static::assertEquals('loggedin', $data[1]);
|
||||||
|
@ -76,7 +76,7 @@ class PluginManagerTest extends \Shaarli\TestCase
|
||||||
public function testPluginWithPhpError(): void
|
public function testPluginWithPhpError(): void
|
||||||
{
|
{
|
||||||
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
PluginManager::$PLUGINS_PATH = self::$pluginPath;
|
||||||
$this->pluginManager->load(array(self::$pluginName));
|
$this->pluginManager->load([self::$pluginName]);
|
||||||
|
|
||||||
$this->assertTrue(function_exists('hook_test_error'));
|
$this->assertTrue(function_exists('hook_test_error'));
|
||||||
|
|
||||||
|
|
|
@ -103,10 +103,10 @@ class ThumbnailerTest extends TestCase
|
||||||
$objects = scandir($dir);
|
$objects = scandir($dir);
|
||||||
foreach ($objects as $object) {
|
foreach ($objects as $object) {
|
||||||
if ($object != "." && $object != "..") {
|
if ($object != "." && $object != "..") {
|
||||||
if (is_dir($dir."/".$object)) {
|
if (is_dir($dir . "/" . $object)) {
|
||||||
$this->rrmdirContent($dir."/".$object);
|
$this->rrmdirContent($dir . "/" . $object);
|
||||||
} else {
|
} else {
|
||||||
unlink($dir."/".$object);
|
unlink($dir . "/" . $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimeZone's tests
|
* TimeZone's tests
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities' tests
|
* Utilities' tests
|
||||||
*/
|
*/
|
||||||
|
@ -187,7 +188,7 @@ class UtilsTest extends \Shaarli\TestCase
|
||||||
public function testGenerateLocationLoop()
|
public function testGenerateLocationLoop()
|
||||||
{
|
{
|
||||||
$ref = 'http://localhost/?test';
|
$ref = 'http://localhost/?test';
|
||||||
$this->assertEquals('./?', generateLocation($ref, 'localhost', array('test')));
|
$this->assertEquals('./?', generateLocation($ref, 'localhost', ['test']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -313,15 +314,15 @@ class UtilsTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testHumanBytes()
|
public function testHumanBytes()
|
||||||
{
|
{
|
||||||
$this->assertEquals('2'. t('kiB'), human_bytes(2 * 1024));
|
$this->assertEquals('2' . t('kiB'), human_bytes(2 * 1024));
|
||||||
$this->assertEquals('2'. t('kiB'), human_bytes(strval(2 * 1024)));
|
$this->assertEquals('2' . t('kiB'), human_bytes(strval(2 * 1024)));
|
||||||
$this->assertEquals('2'. t('MiB'), human_bytes(2 * (pow(1024, 2))));
|
$this->assertEquals('2' . t('MiB'), human_bytes(2 * (pow(1024, 2))));
|
||||||
$this->assertEquals('2'. t('MiB'), human_bytes(strval(2 * (pow(1024, 2)))));
|
$this->assertEquals('2' . t('MiB'), human_bytes(strval(2 * (pow(1024, 2)))));
|
||||||
$this->assertEquals('2'. t('GiB'), human_bytes(2 * (pow(1024, 3))));
|
$this->assertEquals('2' . t('GiB'), human_bytes(2 * (pow(1024, 3))));
|
||||||
$this->assertEquals('2'. t('GiB'), human_bytes(strval(2 * (pow(1024, 3)))));
|
$this->assertEquals('2' . t('GiB'), human_bytes(strval(2 * (pow(1024, 3)))));
|
||||||
$this->assertEquals('374'. t('B'), human_bytes(374));
|
$this->assertEquals('374' . t('B'), human_bytes(374));
|
||||||
$this->assertEquals('374'. t('B'), human_bytes('374'));
|
$this->assertEquals('374' . t('B'), human_bytes('374'));
|
||||||
$this->assertEquals('232'. t('kiB'), human_bytes(237481));
|
$this->assertEquals('232' . t('kiB'), human_bytes(237481));
|
||||||
$this->assertEquals(t('Unlimited'), human_bytes('0'));
|
$this->assertEquals(t('Unlimited'), human_bytes('0'));
|
||||||
$this->assertEquals(t('Unlimited'), human_bytes(0));
|
$this->assertEquals(t('Unlimited'), human_bytes(0));
|
||||||
$this->assertEquals(t('Setting not set'), human_bytes(''));
|
$this->assertEquals(t('Setting not set'), human_bytes(''));
|
||||||
|
@ -332,9 +333,9 @@ class UtilsTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetMaxUploadSize()
|
public function testGetMaxUploadSize()
|
||||||
{
|
{
|
||||||
$this->assertEquals('1'. t('MiB'), get_max_upload_size(2097152, '1024k'));
|
$this->assertEquals('1' . t('MiB'), get_max_upload_size(2097152, '1024k'));
|
||||||
$this->assertEquals('1'. t('MiB'), get_max_upload_size('1m', '2m'));
|
$this->assertEquals('1' . t('MiB'), get_max_upload_size('1m', '2m'));
|
||||||
$this->assertEquals('100'. t('B'), get_max_upload_size(100, 100));
|
$this->assertEquals('100' . t('B'), get_max_upload_size(100, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Api;
|
namespace Shaarli\Api;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
@ -80,7 +81,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||||
$env = Environment::mock([
|
$env = Environment::mock([
|
||||||
'REQUEST_METHOD' => 'GET',
|
'REQUEST_METHOD' => 'GET',
|
||||||
'REQUEST_URI' => '/echo',
|
'REQUEST_URI' => '/echo',
|
||||||
'HTTP_AUTHORIZATION'=> 'Bearer ' . ApiUtilsTest::generateValidJwtToken('NapoleonWasALizard'),
|
'HTTP_AUTHORIZATION' => 'Bearer ' . ApiUtilsTest::generateValidJwtToken('NapoleonWasALizard'),
|
||||||
]);
|
]);
|
||||||
$request = Request::createFromEnvironment($env);
|
$request = Request::createFromEnvironment($env);
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
@ -196,7 +197,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||||
$env = Environment::mock([
|
$env = Environment::mock([
|
||||||
'REQUEST_METHOD' => 'GET',
|
'REQUEST_METHOD' => 'GET',
|
||||||
'REQUEST_URI' => '/echo',
|
'REQUEST_URI' => '/echo',
|
||||||
'HTTP_AUTHORIZATION'=> 'Bearer jwt',
|
'HTTP_AUTHORIZATION' => 'Bearer jwt',
|
||||||
]);
|
]);
|
||||||
$request = Request::createFromEnvironment($env);
|
$request = Request::createFromEnvironment($env);
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
@ -219,7 +220,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||||
$env = Environment::mock([
|
$env = Environment::mock([
|
||||||
'REQUEST_METHOD' => 'GET',
|
'REQUEST_METHOD' => 'GET',
|
||||||
'REQUEST_URI' => '/echo',
|
'REQUEST_URI' => '/echo',
|
||||||
'HTTP_AUTHORIZATION'=> 'PolarBearer jwt',
|
'HTTP_AUTHORIZATION' => 'PolarBearer jwt',
|
||||||
]);
|
]);
|
||||||
$request = Request::createFromEnvironment($env);
|
$request = Request::createFromEnvironment($env);
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
@ -245,7 +246,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||||
$env = Environment::mock([
|
$env = Environment::mock([
|
||||||
'REQUEST_METHOD' => 'GET',
|
'REQUEST_METHOD' => 'GET',
|
||||||
'REQUEST_URI' => '/echo',
|
'REQUEST_URI' => '/echo',
|
||||||
'HTTP_AUTHORIZATION'=> 'Bearer jwt',
|
'HTTP_AUTHORIZATION' => 'Bearer jwt',
|
||||||
]);
|
]);
|
||||||
$request = Request::createFromEnvironment($env);
|
$request = Request::createFromEnvironment($env);
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
|
|
@ -32,10 +32,10 @@ class ApiUtilsTest extends \Shaarli\TestCase
|
||||||
"alg": "HS512"
|
"alg": "HS512"
|
||||||
}');
|
}');
|
||||||
$payload = Base64Url::encode('{
|
$payload = Base64Url::encode('{
|
||||||
"iat": '. time() .'
|
"iat": ' . time() . '
|
||||||
}');
|
}');
|
||||||
$signature = Base64Url::encode(hash_hmac('sha512', $header .'.'. $payload, $secret, true));
|
$signature = Base64Url::encode(hash_hmac('sha512', $header . '.' . $payload, $secret, true));
|
||||||
return $header .'.'. $payload .'.'. $signature;
|
return $header . '.' . $payload . '.' . $signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
@ -106,7 +107,7 @@ class InfoTest extends TestCase
|
||||||
$title = 'My bookmarks';
|
$title = 'My bookmarks';
|
||||||
$headerLink = 'http://shaarli.tld';
|
$headerLink = 'http://shaarli.tld';
|
||||||
$timezone = 'Europe/Paris';
|
$timezone = 'Europe/Paris';
|
||||||
$enabledPlugins = array('foo', 'bar');
|
$enabledPlugins = ['foo', 'bar'];
|
||||||
$defaultPrivateLinks = true;
|
$defaultPrivateLinks = true;
|
||||||
$this->conf->set('general.title', $title);
|
$this->conf->set('general.title', $title);
|
||||||
$this->conf->set('general.header_link', $headerLink);
|
$this->conf->set('general.header_link', $headerLink);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
@ -329,7 +330,7 @@ class GetLinksTest extends \Shaarli\TestCase
|
||||||
// URL encoding
|
// URL encoding
|
||||||
$env = Environment::mock([
|
$env = Environment::mock([
|
||||||
'REQUEST_METHOD' => 'GET',
|
'REQUEST_METHOD' => 'GET',
|
||||||
'QUERY_STRING' => 'searchterm='. urlencode('@web')
|
'QUERY_STRING' => 'searchterm=' . urlencode('@web')
|
||||||
]);
|
]);
|
||||||
$request = Request::createFromEnvironment($env);
|
$request = Request::createFromEnvironment($env);
|
||||||
$response = $this->controller->getLinks($request, new Response());
|
$response = $this->controller->getLinks($request, new Response());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use malkusch\lock\mutex\NoMutex;
|
use malkusch\lock\mutex\NoMutex;
|
||||||
|
|
|
@ -185,7 +185,7 @@ class BookmarkArrayTest extends TestCase
|
||||||
$this->assertCount(3, $array);
|
$this->assertCount(3, $array);
|
||||||
|
|
||||||
foreach ($array as $id => $bookmark) {
|
foreach ($array as $id => $bookmark) {
|
||||||
$this->assertEquals(${'bookmark'. $id}, $bookmark);
|
$this->assertEquals(${'bookmark' . $id}, $bookmark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link datastore tests
|
* Link datastore tests
|
||||||
*/
|
*/
|
||||||
|
@ -82,15 +83,15 @@ class BookmarkFileServiceTest extends TestCase
|
||||||
unlink(self::$testDatastore);
|
unlink(self::$testDatastore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(self::$testConf .'.json.php')) {
|
if (file_exists(self::$testConf . '.json.php')) {
|
||||||
unlink(self::$testConf .'.json.php');
|
unlink(self::$testConf . '.json.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(self::$testUpdates)) {
|
if (file_exists(self::$testUpdates)) {
|
||||||
unlink(self::$testUpdates);
|
unlink(self::$testUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->conf->set('resource.datastore', self::$testDatastore);
|
$this->conf->set('resource.datastore', self::$testDatastore);
|
||||||
$this->conf->set('resource.updates', self::$testUpdates);
|
$this->conf->set('resource.updates', self::$testUpdates);
|
||||||
|
|
|
@ -417,28 +417,28 @@ class BookmarkFilterTest extends TestCase
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||||
array($tags, $terms)
|
[$tags, $terms]
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
2,
|
2,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||||
array('', $terms)
|
['', $terms]
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||||
array(false, 'PSR-2')
|
[false, 'PSR-2']
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
BookmarkFilter::$FILTER_TAG | BookmarkFilter::$FILTER_TEXT,
|
||||||
array($tags, '')
|
[$tags, '']
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
|
|
@ -52,7 +52,7 @@ class BookmarkInitializerTest extends TestCase
|
||||||
unlink(self::$testDatastore);
|
unlink(self::$testDatastore);
|
||||||
}
|
}
|
||||||
|
|
||||||
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->conf->set('resource.datastore', self::$testDatastore);
|
$this->conf->set('resource.datastore', self::$testDatastore);
|
||||||
$this->pluginManager = new PluginManager($this->conf);
|
$this->pluginManager = new PluginManager($this->conf);
|
||||||
|
|
|
@ -167,7 +167,7 @@ class BookmarkTest extends TestCase
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContainsPolyfill('- ID: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- ID: ' . PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +186,7 @@ class BookmarkTest extends TestCase
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContainsPolyfill('- ShortUrl: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- ShortUrl: ' . PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,7 +205,7 @@ class BookmarkTest extends TestCase
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContainsPolyfill('- Created: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- Created: ' . PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -142,7 +142,7 @@ class LinkUtilsTest extends TestCase
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
// OpenGraph multiple properties both end with noise
|
// OpenGraph multiple properties both end with noise
|
||||||
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
|
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" ' .
|
||||||
'tag2="content2" content="' . $description . '" tag3="content3">';
|
'tag2="content2" content="' . $description . '" tag3="content3">';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class LinkUtilsTest extends TestCase
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
// OpenGraph reversed multiple properties both end with noise
|
// OpenGraph reversed multiple properties both end with noise
|
||||||
$html = '<meta tag1="content1" content="' . $description . '" tag2="content2" '.
|
$html = '<meta tag1="content1" content="' . $description . '" tag2="content2" ' .
|
||||||
'property="og:unrelated1 og:description og:unrelated2" tag3="content3">';
|
'property="og:unrelated1 og:description og:unrelated2" tag3="content3">';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class LinkUtilsTest extends TestCase
|
||||||
$html = '<meta property="og:description" content="' . $description . '">';
|
$html = '<meta property="og:description" content="' . $description . '">';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
|
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" ' .
|
||||||
'tag2="content2" content="' . $description . '" tag3="content3">';
|
'tag2="content2" content="' . $description . '" tag3="content3">';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ class LinkUtilsTest extends TestCase
|
||||||
$html = '<meta property="og:description" content=\'' . $description . '\'>';
|
$html = '<meta property="og:description" content=\'' . $description . '\'>';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
|
$html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" ' .
|
||||||
'tag2="content2" content=\'' . $description . '\' tag3="content3">';
|
'tag2="content2" content=\'' . $description . '\' tag3="content3">';
|
||||||
$this->assertEquals($description, html_extract_tag('description', $html));
|
$this->assertEquals($description, html_extract_tag('description', $html));
|
||||||
|
|
||||||
|
@ -247,9 +247,9 @@ class LinkUtilsTest extends TestCase
|
||||||
|
|
||||||
public function testHtmlExtractDescriptionFromGoogleRealCase(): void
|
public function testHtmlExtractDescriptionFromGoogleRealCase(): void
|
||||||
{
|
{
|
||||||
$html = 'id="gsr"><meta content="Fêtes de fin d\'année" property="twitter:title"><meta '.
|
$html = 'id="gsr"><meta content="Fêtes de fin d\'année" property="twitter:title"><meta ' .
|
||||||
'content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="twitter:description">'.
|
'content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="twitter:description">' .
|
||||||
'<meta content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="og:description">'.
|
'<meta content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="og:description">' .
|
||||||
'<meta content="summary_large_image" property="twitter:card"><meta co'
|
'<meta content="summary_large_image" property="twitter:card"><meta co'
|
||||||
;
|
;
|
||||||
$this->assertSame('Bonnes fêtes de fin d\'année ! #GoogleDoodle', html_extract_tag('description', $html));
|
$this->assertSame('Bonnes fêtes de fin d\'année ! #GoogleDoodle', html_extract_tag('description', $html));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Config;
|
namespace Shaarli\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,13 +30,13 @@ class ConfigManagerTest extends \Shaarli\TestCase
|
||||||
$this->conf->set('paramInt', 42);
|
$this->conf->set('paramInt', 42);
|
||||||
$this->conf->set('paramString', 'value1');
|
$this->conf->set('paramString', 'value1');
|
||||||
$this->conf->set('paramBool', false);
|
$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->set('paramNull', null);
|
||||||
|
|
||||||
$this->assertEquals(42, $this->conf->get('paramInt'));
|
$this->assertEquals(42, $this->conf->get('paramInt'));
|
||||||
$this->assertEquals('value1', $this->conf->get('paramString'));
|
$this->assertEquals('value1', $this->conf->get('paramString'));
|
||||||
$this->assertFalse($this->conf->get('paramBool'));
|
$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'));
|
$this->assertEquals(null, $this->conf->get('paramNull'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ class ConfigManagerTest extends \Shaarli\TestCase
|
||||||
$this->conf->set('paramInt', 42);
|
$this->conf->set('paramInt', 42);
|
||||||
$this->conf->set('paramString', 'value1');
|
$this->conf->set('paramString', 'value1');
|
||||||
$this->conf->set('paramBool', false);
|
$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->set('paramNull', null);
|
||||||
|
|
||||||
$this->conf->setConfigFile('tests/utils/config/configTmp');
|
$this->conf->setConfigFile('tests/utils/config/configTmp');
|
||||||
|
@ -62,7 +63,7 @@ class ConfigManagerTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(42, $this->conf->get('paramInt'));
|
$this->assertEquals(42, $this->conf->get('paramInt'));
|
||||||
$this->assertEquals('value1', $this->conf->get('paramString'));
|
$this->assertEquals('value1', $this->conf->get('paramString'));
|
||||||
$this->assertFalse($this->conf->get('paramBool'));
|
$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'));
|
$this->assertEquals(null, $this->conf->get('paramNull'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ class ConfigManagerTest extends \Shaarli\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
|
$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
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Config;
|
namespace Shaarli\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +38,7 @@ class ConfigPhpTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testReadNonExistent()
|
public function testReadNonExistent()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array(), $this->configIO->read('nope'));
|
$this->assertEquals([], $this->configIO->read('nope'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,16 +61,16 @@ class ConfigPhpTest extends \Shaarli\TestCase
|
||||||
public function testWriteNew()
|
public function testWriteNew()
|
||||||
{
|
{
|
||||||
$dataFile = 'tests/utils/config/configWrite.php';
|
$dataFile = 'tests/utils/config/configWrite.php';
|
||||||
$data = array(
|
$data = [
|
||||||
'login' => 'root',
|
'login' => 'root',
|
||||||
'redirector' => 'lala',
|
'redirector' => 'lala',
|
||||||
'config' => array(
|
'config' => [
|
||||||
'DATASTORE' => 'data/datastore.php',
|
'DATASTORE' => 'data/datastore.php',
|
||||||
),
|
],
|
||||||
'plugins' => array(
|
'plugins' => [
|
||||||
'WALLABAG_VERSION' => '1',
|
'WALLABAG_VERSION' => '1',
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
$this->configIO->write($dataFile, $data);
|
$this->configIO->write($dataFile, $data);
|
||||||
$expected = '<?php
|
$expected = '<?php
|
||||||
$GLOBALS[\'login\'] = \'root\';
|
$GLOBALS[\'login\'] = \'root\';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Config;
|
namespace Shaarli\Config;
|
||||||
|
|
||||||
use Shaarli\Config\Exception\PluginConfigOrderException;
|
use Shaarli\Config\Exception\PluginConfigOrderException;
|
||||||
|
@ -35,12 +36,16 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
|
|
||||||
mkdir($path = __DIR__ . '/folder');
|
mkdir($path = __DIR__ . '/folder');
|
||||||
PluginManager::$PLUGINS_PATH = $path;
|
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);
|
$out = save_plugin_config($data);
|
||||||
$this->assertEquals($expected, $out);
|
$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);
|
rmdir($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +56,13 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
$this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class);
|
$this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class);
|
||||||
|
|
||||||
$data = array(
|
$data = [
|
||||||
'plugin2' => 0,
|
'plugin2' => 0,
|
||||||
'plugin3' => 0,
|
'plugin3' => 0,
|
||||||
'order_plugin3' => 0,
|
'order_plugin3' => 0,
|
||||||
'plugin4' => 0,
|
'plugin4' => 0,
|
||||||
'order_plugin4' => 0,
|
'order_plugin4' => 0,
|
||||||
);
|
];
|
||||||
|
|
||||||
save_plugin_config($data);
|
save_plugin_config($data);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +72,7 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testSavePluginConfigEmpty()
|
public function testSavePluginConfigEmpty()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array(), save_plugin_config(array()));
|
$this->assertEquals([], save_plugin_config([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,14 +80,14 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testValidatePluginOrderValid()
|
public function testValidatePluginOrderValid()
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = [
|
||||||
'order_plugin1' => 2,
|
'order_plugin1' => 2,
|
||||||
'plugin2' => 0,
|
'plugin2' => 0,
|
||||||
'plugin3' => 0,
|
'plugin3' => 0,
|
||||||
'order_plugin3' => 1,
|
'order_plugin3' => 1,
|
||||||
'plugin4' => 0,
|
'plugin4' => 0,
|
||||||
'order_plugin4' => 5,
|
'order_plugin4' => 5,
|
||||||
);
|
];
|
||||||
|
|
||||||
$this->assertTrue(validate_plugin_order($data));
|
$this->assertTrue(validate_plugin_order($data));
|
||||||
}
|
}
|
||||||
|
@ -92,11 +97,11 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testValidatePluginOrderInvalid()
|
public function testValidatePluginOrderInvalid()
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = [
|
||||||
'order_plugin1' => 2,
|
'order_plugin1' => 2,
|
||||||
'order_plugin3' => 1,
|
'order_plugin3' => 1,
|
||||||
'order_plugin4' => 1,
|
'order_plugin4' => 1,
|
||||||
);
|
];
|
||||||
|
|
||||||
$this->assertFalse(validate_plugin_order($data));
|
$this->assertFalse(validate_plugin_order($data));
|
||||||
}
|
}
|
||||||
|
@ -106,20 +111,20 @@ class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testLoadPluginParameterValues()
|
public function testLoadPluginParameterValues()
|
||||||
{
|
{
|
||||||
$plugins = array(
|
$plugins = [
|
||||||
'plugin_name' => array(
|
'plugin_name' => [
|
||||||
'parameters' => array(
|
'parameters' => [
|
||||||
'param1' => array('value' => true),
|
'param1' => ['value' => true],
|
||||||
'param2' => array('value' => false),
|
'param2' => ['value' => false],
|
||||||
'param3' => array('value' => ''),
|
'param3' => ['value' => ''],
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$parameters = array(
|
$parameters = [
|
||||||
'param1' => 'value1',
|
'param1' => 'value1',
|
||||||
'param2' => 'value2',
|
'param2' => 'value2',
|
||||||
);
|
];
|
||||||
|
|
||||||
$result = load_plugin_parameter_values($plugins, $parameters);
|
$result = load_plugin_parameter_values($plugins, $parameters);
|
||||||
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
|
$this->assertEquals('value1', $result['plugin_name']['parameters']['param1']['value']);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PageCache tests
|
* PageCache tests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Shaarli\Feed;
|
namespace Shaarli\Feed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,13 +66,13 @@ class FeedBuilderTest extends TestCase
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
self::$serverInfo = array(
|
self::$serverInfo = [
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/index.php',
|
'SCRIPT_NAME' => '/index.php',
|
||||||
'REQUEST_URI' => '/feed/atom',
|
'REQUEST_URI' => '/feed/atom',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,10 +149,10 @@ class FeedBuilderTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testBuildDataFiltered()
|
public function testBuildDataFiltered()
|
||||||
{
|
{
|
||||||
$criteria = array(
|
$criteria = [
|
||||||
'searchtags' => 'stuff',
|
'searchtags' => 'stuff',
|
||||||
'searchterm' => 'beard',
|
'searchterm' => 'beard',
|
||||||
);
|
];
|
||||||
$feedBuilder = new FeedBuilder(
|
$feedBuilder = new FeedBuilder(
|
||||||
self::$bookmarkService,
|
self::$bookmarkService,
|
||||||
self::$formatter,
|
self::$formatter,
|
||||||
|
@ -172,9 +172,9 @@ class FeedBuilderTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testBuildDataCount()
|
public function testBuildDataCount()
|
||||||
{
|
{
|
||||||
$criteria = array(
|
$criteria = [
|
||||||
'nb' => '3',
|
'nb' => '3',
|
||||||
);
|
];
|
||||||
$feedBuilder = new FeedBuilder(
|
$feedBuilder = new FeedBuilder(
|
||||||
self::$bookmarkService,
|
self::$bookmarkService,
|
||||||
self::$formatter,
|
self::$formatter,
|
||||||
|
@ -259,13 +259,13 @@ class FeedBuilderTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testBuildDataServerSubdir()
|
public function testBuildDataServerSubdir()
|
||||||
{
|
{
|
||||||
$serverInfo = array(
|
$serverInfo = [
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '8080',
|
'SERVER_PORT' => '8080',
|
||||||
'SCRIPT_NAME' => '/~user/shaarli/index.php',
|
'SCRIPT_NAME' => '/~user/shaarli/index.php',
|
||||||
'REQUEST_URI' => '/~user/shaarli/feed/atom',
|
'REQUEST_URI' => '/~user/shaarli/feed/atom',
|
||||||
);
|
];
|
||||||
$feedBuilder = new FeedBuilder(
|
$feedBuilder = new FeedBuilder(
|
||||||
self::$bookmarkService,
|
self::$bookmarkService,
|
||||||
self::$formatter,
|
self::$formatter,
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BookmarkDefaultFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->formatter = new BookmarkDefaultFormatter($this->conf, true);
|
$this->formatter = new BookmarkDefaultFormatter($this->conf, true);
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,9 @@ class BookmarkDefaultFormatterTest extends TestCase
|
||||||
{
|
{
|
||||||
$description = [];
|
$description = [];
|
||||||
$description[] = 'This a <strong>description</strong>' . PHP_EOL;
|
$description[] = 'This a <strong>description</strong>' . PHP_EOL;
|
||||||
$description[] = 'text https://sub.domain.tld?query=here&for=real#hash more text'. 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[] = 'Also, there is an #hashtag added' . PHP_EOL;
|
||||||
$description[] = ' A N D KEEP SPACES ! '. PHP_EOL;
|
$description[] = ' A N D KEEP SPACES ! ' . PHP_EOL;
|
||||||
|
|
||||||
$bookmark = new Bookmark();
|
$bookmark = new Bookmark();
|
||||||
$bookmark->setDescription(implode('', $description));
|
$bookmark->setDescription(implode('', $description));
|
||||||
|
@ -122,10 +122,10 @@ class BookmarkDefaultFormatterTest extends TestCase
|
||||||
|
|
||||||
$description[0] = 'This a <strong>description</strong><br />';
|
$description[0] = 'This a <strong>description</strong><br />';
|
||||||
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
||||||
$description[1] = 'text <a href="'. $url .'">'. $url .'</a> more text<br />';
|
$description[1] = 'text <a href="' . $url . '">' . $url . '</a> more text<br />';
|
||||||
$description[2] = 'Also, there is an <a href="./add-tag/hashtag" '.
|
$description[2] = 'Also, there is an <a href="./add-tag/hashtag" ' .
|
||||||
'title="Hashtag hashtag">#hashtag</a> added<br />';
|
'title="Hashtag hashtag">#hashtag</a> added<br />';
|
||||||
$description[3] = ' A N D KEEP '.
|
$description[3] = ' A N D KEEP ' .
|
||||||
'SPACES ! <br />';
|
'SPACES ! <br />';
|
||||||
|
|
||||||
$this->assertEquals(implode(PHP_EOL, $description) . PHP_EOL, $link['description']);
|
$this->assertEquals(implode(PHP_EOL, $description) . PHP_EOL, $link['description']);
|
||||||
|
@ -148,7 +148,7 @@ class BookmarkDefaultFormatterTest extends TestCase
|
||||||
$this->assertEquals($root . $short, $link['url']);
|
$this->assertEquals($root . $short, $link['url']);
|
||||||
$this->assertEquals($root . $short, $link['real_url']);
|
$this->assertEquals($root . $short, $link['real_url']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'Text <a href="'. $root .'./add-tag/hashtag" title="Hashtag hashtag">'.
|
'Text <a href="' . $root . './add-tag/hashtag" title="Hashtag hashtag">' .
|
||||||
'#hashtag</a> more text',
|
'#hashtag</a> more text',
|
||||||
$link['description']
|
$link['description']
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function setUp(): void
|
public 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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->formatter = new BookmarkMarkdownExtraFormatter($this->conf, true);
|
$this->formatter = new BookmarkMarkdownExtraFormatter($this->conf, true);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
|
||||||
);
|
);
|
||||||
$this->assertEquals('This is a <strong>bookmark</strong>', $link['title']);
|
$this->assertEquals('This is a <strong>bookmark</strong>', $link['title']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<div class="markdown"><p>'.
|
'<div class="markdown"><p>' .
|
||||||
'<h2>Content</h2><p>`Here is some content</p>'.
|
'<h2>Content</h2><p>`Here is some content</p>' .
|
||||||
'</p></div>',
|
'</p></div>',
|
||||||
$link['description']
|
$link['description']
|
||||||
);
|
);
|
||||||
|
@ -112,21 +112,21 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testFormatExtrraDescription(): void
|
public function testFormatExtrraDescription(): void
|
||||||
{
|
{
|
||||||
$description = 'This a <strong>description</strong>'. PHP_EOL;
|
$description = 'This a <strong>description</strong>' . PHP_EOL;
|
||||||
$description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. 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 .= 'Also, there is an #hashtag added' . PHP_EOL;
|
||||||
$description .= ' A N D KEEP SPACES ! '. PHP_EOL;
|
$description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
|
||||||
$description .= '# Header {.class}'. PHP_EOL;
|
$description .= '# Header {.class}' . PHP_EOL;
|
||||||
|
|
||||||
$bookmark = new Bookmark();
|
$bookmark = new Bookmark();
|
||||||
$bookmark->setDescription($description);
|
$bookmark->setDescription($description);
|
||||||
$link = $this->formatter->format($bookmark);
|
$link = $this->formatter->format($bookmark);
|
||||||
|
|
||||||
$description = '<div class="markdown"><p>';
|
$description = '<div class="markdown"><p>';
|
||||||
$description .= 'This a <strong>description</strong><br />'. PHP_EOL;
|
$description .= 'This a <strong>description</strong><br />' . PHP_EOL;
|
||||||
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
||||||
$description .= 'text <a href="'. $url .'">'. $url .'</a> more text<br />'. PHP_EOL;
|
$description .= 'text <a href="' . $url . '">' . $url . '</a> more text<br />' . PHP_EOL;
|
||||||
$description .= 'Also, there is an <a href="./add-tag/hashtag">#hashtag</a> added<br />'. PHP_EOL;
|
$description .= 'Also, there is an <a href="./add-tag/hashtag">#hashtag</a> added<br />' . PHP_EOL;
|
||||||
$description .= 'A N D KEEP SPACES ! </p>' . PHP_EOL;
|
$description .= 'A N D KEEP SPACES ! </p>' . PHP_EOL;
|
||||||
$description .= '<h1 class="class">Header</h1>';
|
$description .= '<h1 class="class">Header</h1>';
|
||||||
$description .= '</div>';
|
$description .= '</div>';
|
||||||
|
@ -148,7 +148,7 @@ class BookmarkMarkdownExtraFormatterTest extends TestCase
|
||||||
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
|
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
|
||||||
|
|
||||||
$description = '<div class="markdown"><p>';
|
$description = '<div class="markdown"><p>';
|
||||||
$description .= 'Text <a href="'. $root .'./add-tag/hashtag">#hashtag</a> more text';
|
$description .= 'Text <a href="' . $root . './add-tag/hashtag">#hashtag</a> more text';
|
||||||
$description .= '</p></div>';
|
$description .= '</p></div>';
|
||||||
|
|
||||||
$link = $this->formatter->format($bookmark);
|
$link = $this->formatter->format($bookmark);
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BookmarkMarkdownFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->formatter = new BookmarkMarkdownFormatter($this->conf, true);
|
$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('This is a <strong>bookmark</strong>', $link['title']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'<div class="markdown"><p>'.
|
'<div class="markdown"><p>' .
|
||||||
'<h2>Content</h2><p>`Here is some content</p>'.
|
'<h2>Content</h2><p>`Here is some content</p>' .
|
||||||
'</p></div>',
|
'</p></div>',
|
||||||
$link['description']
|
$link['description']
|
||||||
);
|
);
|
||||||
|
@ -112,20 +112,20 @@ class BookmarkMarkdownFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testFormatDescription()
|
public function testFormatDescription()
|
||||||
{
|
{
|
||||||
$description = 'This a <strong>description</strong>'. PHP_EOL;
|
$description = 'This a <strong>description</strong>' . PHP_EOL;
|
||||||
$description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. 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 .= 'Also, there is an #hashtag added' . PHP_EOL;
|
||||||
$description .= ' A N D KEEP SPACES ! '. PHP_EOL;
|
$description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
|
||||||
|
|
||||||
$bookmark = new Bookmark();
|
$bookmark = new Bookmark();
|
||||||
$bookmark->setDescription($description);
|
$bookmark->setDescription($description);
|
||||||
$link = $this->formatter->format($bookmark);
|
$link = $this->formatter->format($bookmark);
|
||||||
|
|
||||||
$description = '<div class="markdown"><p>';
|
$description = '<div class="markdown"><p>';
|
||||||
$description .= 'This a <strong>description</strong><br />'. PHP_EOL;
|
$description .= 'This a <strong>description</strong><br />' . PHP_EOL;
|
||||||
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
||||||
$description .= 'text <a href="'. $url .'">'. $url .'</a> more text<br />'. PHP_EOL;
|
$description .= 'text <a href="' . $url . '">' . $url . '</a> more text<br />' . PHP_EOL;
|
||||||
$description .= 'Also, there is an <a href="./add-tag/hashtag">#hashtag</a> added<br />'. PHP_EOL;
|
$description .= 'Also, there is an <a href="./add-tag/hashtag">#hashtag</a> added<br />' . PHP_EOL;
|
||||||
$description .= 'A N D KEEP SPACES ! ';
|
$description .= 'A N D KEEP SPACES ! ';
|
||||||
$description .= '</p></div>';
|
$description .= '</p></div>';
|
||||||
|
|
||||||
|
@ -137,11 +137,11 @@ class BookmarkMarkdownFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testFormatDescriptionWithSearchHighlight()
|
public function testFormatDescriptionWithSearchHighlight()
|
||||||
{
|
{
|
||||||
$description = 'This a <strong>description</strong>'. PHP_EOL;
|
$description = 'This a <strong>description</strong>' . PHP_EOL;
|
||||||
$description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. 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 .= 'Also, there is an #hashtag added' . PHP_EOL;
|
||||||
$description .= ' A N D KEEP SPACES ! '. PHP_EOL;
|
$description .= ' A N D KEEP SPACES ! ' . PHP_EOL;
|
||||||
$description .= 'And [yet another link](https://other.domain.tld)'. PHP_EOL;
|
$description .= 'And [yet another link](https://other.domain.tld)' . PHP_EOL;
|
||||||
|
|
||||||
$bookmark = new Bookmark();
|
$bookmark = new Bookmark();
|
||||||
$bookmark->setDescription($description);
|
$bookmark->setDescription($description);
|
||||||
|
@ -164,9 +164,9 @@ class BookmarkMarkdownFormatterTest extends TestCase
|
||||||
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
$url = 'https://sub.domain.tld?query=here&for=real#hash';
|
||||||
$highlighted = 'https://<span class="search-highlight">sub</span>.domain.tld';
|
$highlighted = 'https://<span class="search-highlight">sub</span>.domain.tld';
|
||||||
$highlighted .= '?query=here&for=real#<span class="search-highlight">hash</span>';
|
$highlighted .= '?query=here&for=real#<span class="search-highlight">hash</span>';
|
||||||
$description .= 'text <a href="'. $url .'">'. $highlighted .'</a> more text<br />'. PHP_EOL;
|
$description .= 'text <a href="' . $url . '">' . $highlighted . '</a> more text<br />' . PHP_EOL;
|
||||||
$description .= 'Also, there is an <a href="./add-tag/hashtag">#<span class="search-highlight">hasht</span>' .
|
$description .= 'Also, there is an <a href="./add-tag/hashtag">#<span class="search-highlight">hasht</span>' .
|
||||||
'ag</a> added<br />'. PHP_EOL;
|
'ag</a> added<br />' . PHP_EOL;
|
||||||
$description .= 'A N D KEEP SPACES !<br />' . PHP_EOL;
|
$description .= 'A N D KEEP SPACES !<br />' . PHP_EOL;
|
||||||
$description .= 'And <a href="https://other.domain.tld">' .
|
$description .= 'And <a href="https://other.domain.tld">' .
|
||||||
'<span class="search-highlight">yet another link</span></a>';
|
'<span class="search-highlight">yet another link</span></a>';
|
||||||
|
@ -189,7 +189,7 @@ class BookmarkMarkdownFormatterTest extends TestCase
|
||||||
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
|
$this->formatter->addContextData('index_url', $root = 'https://domain.tld/hithere/');
|
||||||
|
|
||||||
$description = '<div class="markdown"><p>';
|
$description = '<div class="markdown"><p>';
|
||||||
$description .= 'Text <a href="'. $root .'./add-tag/hashtag">#hashtag</a> more text';
|
$description .= 'Text <a href="' . $root . './add-tag/hashtag">#hashtag</a> more text';
|
||||||
$description .= '</p></div>';
|
$description .= '</p></div>';
|
||||||
|
|
||||||
$link = $this->formatter->format($bookmark);
|
$link = $this->formatter->format($bookmark);
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BookmarkRawFormatterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->formatter = new BookmarkRawFormatter($this->conf, true);
|
$this->formatter = new BookmarkRawFormatter($this->conf, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class FormatterFactoryTest extends TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
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->conf = new ConfigManager(self::$testConf);
|
||||||
$this->factory = new FormatterFactory($this->conf, true);
|
$this->factory = new FormatterFactory($this->conf, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,8 @@ class ShaarliAdminMiddlewareTest extends TestCase
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
|
||||||
/** @var Response $result */
|
/** @var Response $result */
|
||||||
$result = $this->middleware->__invoke($request, $response, function () {});
|
$result = $this->middleware->__invoke($request, $response, function () {
|
||||||
|
});
|
||||||
|
|
||||||
static::assertSame(302, $result->getStatusCode());
|
static::assertSame(302, $result->getStatusCode());
|
||||||
static::assertSame(
|
static::assertSame(
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ShaarliMiddlewareTest extends TestCase
|
||||||
$controller = function (): void {
|
$controller = function (): void {
|
||||||
$exception = new LoginBannedException();
|
$exception = new LoginBannedException();
|
||||||
|
|
||||||
throw new $exception;
|
throw new $exception();
|
||||||
};
|
};
|
||||||
|
|
||||||
$pageBuilder = $this->createMock(PageBuilder::class);
|
$pageBuilder = $this->createMock(PageBuilder::class);
|
||||||
|
@ -148,7 +148,8 @@ class ShaarliMiddlewareTest extends TestCase
|
||||||
return $uri;
|
return $uri;
|
||||||
});
|
});
|
||||||
|
|
||||||
$dummyException = new class() extends \Exception {};
|
$dummyException = new class () extends \Exception {
|
||||||
|
};
|
||||||
|
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
$controller = function () use ($dummyException): void {
|
$controller = function () use ($dummyException): void {
|
||||||
|
|
|
@ -122,8 +122,7 @@ class ConfigureControllerTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
return $parameters[$key];
|
return $parameters[$key];
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
|
|
||||||
|
@ -137,8 +136,7 @@ class ConfigureControllerTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
static::assertSame($parametersConfigMapping[$key], $value);
|
static::assertSame($parametersConfigMapping[$key], $value);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
$result = $this->controller->save($request, $response);
|
$result = $this->controller->save($request, $response);
|
||||||
static::assertSame(302, $result->getStatusCode());
|
static::assertSame(302, $result->getStatusCode());
|
||||||
|
|
|
@ -80,7 +80,10 @@ class ExportControllerTest extends TestCase
|
||||||
string $selection,
|
string $selection,
|
||||||
bool $prependNoteUrl,
|
bool $prependNoteUrl,
|
||||||
string $indexUrl
|
string $indexUrl
|
||||||
) use ($parameters, $bookmarks): array {
|
) use (
|
||||||
|
$parameters,
|
||||||
|
$bookmarks
|
||||||
|
): array {
|
||||||
static::assertInstanceOf(BookmarkRawFormatter::class, $formatter);
|
static::assertInstanceOf(BookmarkRawFormatter::class, $formatter);
|
||||||
static::assertSame($parameters['selection'], $selection);
|
static::assertSame($parameters['selection'], $selection);
|
||||||
static::assertTrue($prependNoteUrl);
|
static::assertTrue($prependNoteUrl);
|
||||||
|
|
|
@ -74,7 +74,10 @@ class ImportControllerTest extends TestCase
|
||||||
function (
|
function (
|
||||||
array $post,
|
array $post,
|
||||||
UploadedFileInterface $file
|
UploadedFileInterface $file
|
||||||
) use ($parameters, $requestFile): string {
|
) use (
|
||||||
|
$parameters,
|
||||||
|
$requestFile
|
||||||
|
): string {
|
||||||
static::assertSame($parameters, $post);
|
static::assertSame($parameters, $post);
|
||||||
static::assertSame($requestFile, $file);
|
static::assertSame($requestFile, $file);
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,12 @@ class PasswordControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
$request = $this->createMock(Request::class);
|
$request = $this->createMock(Request::class);
|
||||||
$request->method('getParam')->willReturnCallback(function (string $key): string {
|
$request->method('getParam')->willReturnCallback(function (string $key): string {
|
||||||
if ('oldpassword' === $key) {
|
if ('oldpassword' === $key) {
|
||||||
return 'old';
|
return 'old';
|
||||||
}
|
}
|
||||||
if ('setpassword' === $key) {
|
if ('setpassword' === $key) {
|
||||||
return 'new';
|
return 'new';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,13 +29,17 @@ class PluginsControllerTest extends TestCase
|
||||||
|
|
||||||
mkdir($path = __DIR__ . '/folder');
|
mkdir($path = __DIR__ . '/folder');
|
||||||
PluginManager::$PLUGINS_PATH = $path;
|
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
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
$path = __DIR__ . '/folder';
|
$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);
|
rmdir($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,5 +365,4 @@ class SaveBookmarkTest extends TestCase
|
||||||
|
|
||||||
$this->controller->save($request, $response);
|
$this->controller->save($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ShaarliAdminControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->createContainer();
|
$this->createContainer();
|
||||||
|
|
||||||
$this->controller = new class($this->container) extends ShaarliAdminController
|
$this->controller = new class ($this->container) extends ShaarliAdminController
|
||||||
{
|
{
|
||||||
public function checkToken(Request $request): bool
|
public function checkToken(Request $request): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,8 +54,7 @@ class BookmarkListControllerTest extends TestCase
|
||||||
(new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'),
|
(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(2)->setUrl('http://url2.tld')->setTitle('Title 2'),
|
||||||
(new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
|
(new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
|
||||||
], 0, 2)
|
], 0, 2));
|
||||||
);
|
|
||||||
|
|
||||||
$this->container->sessionManager
|
$this->container->sessionManager
|
||||||
->method('getSessionParameter')
|
->method('getSessionParameter')
|
||||||
|
|
|
@ -102,7 +102,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertSame(200, $result->getStatusCode());
|
static::assertSame(200, $result->getStatusCode());
|
||||||
static::assertSame('daily', (string) $result->getBody());
|
static::assertSame('daily', (string) $result->getBody());
|
||||||
static::assertSame(
|
static::assertSame(
|
||||||
'Daily - '. format_date($currentDay, false, true) .' - Shaarli',
|
'Daily - ' . format_date($currentDay, false, true) . ' - Shaarli',
|
||||||
$assignedVariables['pagetitle']
|
$assignedVariables['pagetitle']
|
||||||
);
|
);
|
||||||
static::assertEquals($currentDay, $assignedVariables['dayDate']);
|
static::assertEquals($currentDay, $assignedVariables['dayDate']);
|
||||||
|
@ -225,7 +225,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertSame(200, $result->getStatusCode());
|
static::assertSame(200, $result->getStatusCode());
|
||||||
static::assertSame('daily', (string) $result->getBody());
|
static::assertSame('daily', (string) $result->getBody());
|
||||||
static::assertSame(
|
static::assertSame(
|
||||||
'Daily - '. format_date($currentDay, false, true) .' - Shaarli',
|
'Daily - ' . format_date($currentDay, false, true) . ' - Shaarli',
|
||||||
$assignedVariables['pagetitle']
|
$assignedVariables['pagetitle']
|
||||||
);
|
);
|
||||||
static::assertCount(1, $assignedVariables['linksToDisplay']);
|
static::assertCount(1, $assignedVariables['linksToDisplay']);
|
||||||
|
@ -285,7 +285,9 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertCount(7, $assignedVariables['linksToDisplay']);
|
static::assertCount(7, $assignedVariables['linksToDisplay']);
|
||||||
|
|
||||||
$columnIds = function (array $column): array {
|
$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]));
|
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');
|
$cachedPage->expects(static::once())->method('cache')->with('dailyrss');
|
||||||
|
|
||||||
return $cachedPage;
|
return $cachedPage;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// Save RainTPL assigned variables
|
// Save RainTPL assigned variables
|
||||||
$assignedVariables = [];
|
$assignedVariables = [];
|
||||||
|
@ -390,7 +391,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame(format_date($date, false), $day['date_human']);
|
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::assertCount(1, $day['links']);
|
||||||
static::assertSame(1, $day['links'][0]['id']);
|
static::assertSame(1, $day['links'][0]['id']);
|
||||||
static::assertSame('http://domain.tld/1', $day['links'][0]['url']);
|
static::assertSame('http://domain.tld/1', $day['links'][0]['url']);
|
||||||
|
@ -402,7 +403,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame(format_date($date, false), $day['date_human']);
|
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::assertCount(2, $day['links']);
|
||||||
|
|
||||||
static::assertSame(2, $day['links'][0]['id']);
|
static::assertSame(2, $day['links'][0]['id']);
|
||||||
|
@ -418,7 +419,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame(format_date($date, false), $day['date_human']);
|
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::assertCount(1, $day['links']);
|
||||||
static::assertSame(4, $day['links'][0]['id']);
|
static::assertSame(4, $day['links'][0]['id']);
|
||||||
static::assertSame('http://domain.tld/4', $day['links'][0]['url']);
|
static::assertSame('http://domain.tld/4', $day['links'][0]['url']);
|
||||||
|
@ -647,7 +648,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame('Week 21 (May 18, 2020)', $day['date_human']);
|
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']);
|
static::assertCount(1, $day['links']);
|
||||||
|
|
||||||
$day = $assignedVariables['days'][$dates[1]->format('YW')];
|
$day = $assignedVariables['days'][$dates[1]->format('YW')];
|
||||||
|
@ -656,7 +657,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame('Week 20 (May 11, 2020)', $day['date_human']);
|
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']);
|
static::assertCount(2, $day['links']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +711,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame('May, 2020', $day['date_human']);
|
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']);
|
static::assertCount(1, $day['links']);
|
||||||
|
|
||||||
$day = $assignedVariables['days'][$dates[1]->format('Ym')];
|
$day = $assignedVariables['days'][$dates[1]->format('Ym')];
|
||||||
|
@ -719,7 +720,7 @@ class DailyControllerTest extends TestCase
|
||||||
static::assertEquals($date, $day['date']);
|
static::assertEquals($date, $day['date']);
|
||||||
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
static::assertSame($date->format(\DateTime::RSS), $day['date_rss']);
|
||||||
static::assertSame('April, 2020', $day['date_human']);
|
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']);
|
static::assertCount(2, $day['links']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ class ErrorControllerTest extends TestCase
|
||||||
$result = ($this->controller)(
|
$result = ($this->controller)(
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
new class($message, $errorCode) extends ShaarliFrontException {}
|
new class ($message, $errorCode) extends ShaarliFrontException {
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
static::assertSame($errorCode, $result->getStatusCode());
|
static::assertSame($errorCode, $result->getStatusCode());
|
||||||
|
|
|
@ -118,5 +118,5 @@ trait FrontControllerMockHelper
|
||||||
/**
|
/**
|
||||||
* Force to be used in PHPUnit context.
|
* Force to be used in PHPUnit context.
|
||||||
*/
|
*/
|
||||||
protected abstract function isInTestsContext(): bool;
|
abstract protected function isInTestsContext(): bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ShaarliVisitorControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->createContainer();
|
$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
|
public function assignView(string $key, $value): ShaarliVisitorController
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,12 +130,12 @@ class TagCloudControllerTest extends TestCase
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
->withConsecutive(['render_tagcloud'])
|
->withConsecutive(['render_tagcloud'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
if ('render_tagcloud' === $hook) {
|
if ('render_tagcloud' === $hook) {
|
||||||
static::assertSame('ghi@def@', $data['search_tags']);
|
static::assertSame('ghi@def@', $data['search_tags']);
|
||||||
static::assertCount(1, $data['tags']);
|
static::assertCount(1, $data['tags']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Helper;
|
namespace Shaarli\Helper;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
@ -49,7 +50,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
'0.5.4',
|
'0.5.4',
|
||||||
ApplicationUtils::getVersion(
|
ApplicationUtils::getVersion(
|
||||||
'https://raw.githubusercontent.com/shaarli/Shaarli/'
|
'https://raw.githubusercontent.com/shaarli/Shaarli/'
|
||||||
.'v0.5.4/shaarli_version.php',
|
. 'v0.5.4/shaarli_version.php',
|
||||||
$testTimeout
|
$testTimeout
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -57,7 +58,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
self::$versionPattern,
|
self::$versionPattern,
|
||||||
ApplicationUtils::getVersion(
|
ApplicationUtils::getVersion(
|
||||||
'https://raw.githubusercontent.com/shaarli/Shaarli/'
|
'https://raw.githubusercontent.com/shaarli/Shaarli/'
|
||||||
.'latest/shaarli_version.php',
|
. 'latest/shaarli_version.php',
|
||||||
$testTimeout
|
$testTimeout
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -68,7 +69,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testGetVersionCodeFromFile()
|
public function testGetVersionCodeFromFile()
|
||||||
{
|
{
|
||||||
file_put_contents('sandbox/version.php', '<?php /* 1.2.3 */ ?>'. PHP_EOL);
|
file_put_contents('sandbox/version.php', '<?php /* 1.2.3 */ ?>' . PHP_EOL);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'1.2.3',
|
'1.2.3',
|
||||||
ApplicationUtils::getVersion('sandbox/version.php', 1)
|
ApplicationUtils::getVersion('sandbox/version.php', 1)
|
||||||
|
@ -301,7 +302,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
$conf->set('resource.update_check', 'data/lastupdatecheck.txt');
|
$conf->set('resource.update_check', 'data/lastupdatecheck.txt');
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(),
|
[],
|
||||||
ApplicationUtils::checkResourcePermissions($conf)
|
ApplicationUtils::checkResourcePermissions($conf)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +325,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
$conf->set('resource.raintpl_theme', 'null/tpl/default');
|
$conf->set('resource.raintpl_theme', 'null/tpl/default');
|
||||||
$conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
|
$conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
[
|
||||||
'"null/tpl" directory is not readable',
|
'"null/tpl" directory is not readable',
|
||||||
'"null/tpl/default" directory is not readable',
|
'"null/tpl/default" directory is not readable',
|
||||||
'"null/cache" directory is not readable',
|
'"null/cache" directory is not readable',
|
||||||
|
@ -335,7 +336,7 @@ class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
'"null/pagecache" directory is not writable',
|
'"null/pagecache" directory is not writable',
|
||||||
'"null/tmp" directory is not readable',
|
'"null/tmp" directory is not readable',
|
||||||
'"null/tmp" directory is not writable'
|
'"null/tmp" directory is not writable'
|
||||||
),
|
],
|
||||||
ApplicationUtils::checkResourcePermissions($conf)
|
ApplicationUtils::checkResourcePermissions($conf)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,8 @@ class DailyPageHelperTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider getRssLengthsByType
|
* @dataProvider getRssLengthsByType
|
||||||
*/
|
*/
|
||||||
public function testGeRssLengthsByType(string $type): void {
|
public function testGeRssLengthsByType(string $type): void
|
||||||
|
{
|
||||||
$length = DailyPageHelper::getRssLengthByType($type);
|
$length = DailyPageHelper::getRssLengthByType($type);
|
||||||
|
|
||||||
static::assertIsInt($length);
|
static::assertIsInt($length);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpUtils' tests
|
* HttpUtils' tests
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpUtils' tests
|
* HttpUtils' tests
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,7 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testWithoutProxy()
|
public function testWithoutProxy()
|
||||||
{
|
{
|
||||||
$this->assertFalse(getIpAddressFromProxy(array(), array()));
|
$this->assertFalse(getIpAddressFromProxy([], []));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,8 +24,8 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||||
public function testWithOneForwardedIp()
|
public function testWithOneForwardedIp()
|
||||||
{
|
{
|
||||||
$ip = '1.1.1.1';
|
$ip = '1.1.1.1';
|
||||||
$server = array('HTTP_X_FORWARDED_FOR' => $ip);
|
$server = ['HTTP_X_FORWARDED_FOR' => $ip];
|
||||||
$this->assertEquals($ip, getIpAddressFromProxy($server, array()));
|
$this->assertEquals($ip, getIpAddressFromProxy($server, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,11 +36,11 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||||
$ip = '1.1.1.1';
|
$ip = '1.1.1.1';
|
||||||
$ip2 = '2.2.2.2';
|
$ip2 = '2.2.2.2';
|
||||||
|
|
||||||
$server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
|
$server = ['HTTP_X_FORWARDED_FOR' => $ip . ',' . $ip2];
|
||||||
$this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
|
$this->assertEquals($ip2, getIpAddressFromProxy($server, []));
|
||||||
|
|
||||||
$server = array('HTTP_X_FORWARDED_FOR' => $ip .' , '. $ip2);
|
$server = ['HTTP_X_FORWARDED_FOR' => $ip . ' , ' . $ip2];
|
||||||
$this->assertEquals($ip2, getIpAddressFromProxy($server, array()));
|
$this->assertEquals($ip2, getIpAddressFromProxy($server, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,11 +51,11 @@ class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||||
$ip = '1.1.1.1';
|
$ip = '1.1.1.1';
|
||||||
$ip2 = '2.2.2.2';
|
$ip2 = '2.2.2.2';
|
||||||
|
|
||||||
$server = array('HTTP_X_FORWARDED_FOR' => $ip);
|
$server = ['HTTP_X_FORWARDED_FOR' => $ip];
|
||||||
$this->assertFalse(getIpAddressFromProxy($server, array($ip)));
|
$this->assertFalse(getIpAddressFromProxy($server, [$ip]));
|
||||||
|
|
||||||
$server = array('HTTP_X_FORWARDED_FOR' => $ip .','. $ip2);
|
$server = ['HTTP_X_FORWARDED_FOR' => $ip . ',' . $ip2];
|
||||||
$this->assertEquals($ip2, getIpAddressFromProxy($server, array($ip)));
|
$this->assertEquals($ip2, getIpAddressFromProxy($server, [$ip]));
|
||||||
$this->assertFalse(getIpAddressFromProxy($server, array($ip, $ip2)));
|
$this->assertFalse(getIpAddressFromProxy($server, [$ip, $ip2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpUtils' tests
|
* HttpUtils' tests
|
||||||
*/
|
*/
|
||||||
|
@ -22,24 +23,24 @@ class IndexUrlTest extends TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/',
|
'http://host.tld/',
|
||||||
index_url(
|
index_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/index.php'
|
'SCRIPT_NAME' => '/index.php'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/admin/',
|
'http://host.tld/admin/',
|
||||||
index_url(
|
index_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/index.php'
|
'SCRIPT_NAME' => '/admin/index.php'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -52,24 +53,24 @@ class IndexUrlTest extends TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/page.php',
|
'http://host.tld/page.php',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/page.php'
|
'SCRIPT_NAME' => '/page.php'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/admin/page.php',
|
'http://host.tld/admin/page.php',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/page.php'
|
'SCRIPT_NAME' => '/admin/page.php'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -82,26 +83,26 @@ class IndexUrlTest extends TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/picture-wall',
|
'http://host.tld/picture-wall',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/index.php',
|
'SCRIPT_NAME' => '/index.php',
|
||||||
'REQUEST_URI' => '/picture-wall',
|
'REQUEST_URI' => '/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/admin/picture-wall',
|
'http://host.tld/admin/picture-wall',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/index.php',
|
'SCRIPT_NAME' => '/admin/index.php',
|
||||||
'REQUEST_URI' => '/admin/picture-wall',
|
'REQUEST_URI' => '/admin/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -114,26 +115,26 @@ class IndexUrlTest extends TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/subfolder/picture-wall',
|
'http://host.tld/subfolder/picture-wall',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/subfolder/index.php',
|
'SCRIPT_NAME' => '/subfolder/index.php',
|
||||||
'REQUEST_URI' => '/subfolder/picture-wall',
|
'REQUEST_URI' => '/subfolder/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/subfolder/admin/picture-wall',
|
'http://host.tld/subfolder/admin/picture-wall',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/subfolder/admin/index.php',
|
'SCRIPT_NAME' => '/subfolder/admin/index.php',
|
||||||
'REQUEST_URI' => '/subfolder/admin/picture-wall',
|
'REQUEST_URI' => '/subfolder/admin/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,26 +25,26 @@ class IndexUrlTestWithConstant extends TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://other-host.tld/subfolder/',
|
'http://other-host.tld/subfolder/',
|
||||||
index_url(
|
index_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/index.php',
|
'SCRIPT_NAME' => '/index.php',
|
||||||
'REQUEST_URI' => '/picture-wall',
|
'REQUEST_URI' => '/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://other-host.tld/subfolder/',
|
'http://other-host.tld/subfolder/',
|
||||||
index_url(
|
index_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/index.php',
|
'SCRIPT_NAME' => '/admin/index.php',
|
||||||
'REQUEST_URI' => '/admin/picture-wall',
|
'REQUEST_URI' => '/admin/picture-wall',
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpUtils' tests
|
* HttpUtils' tests
|
||||||
*/
|
*/
|
||||||
|
@ -20,26 +21,26 @@ class PageUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/?p1=v1&p2=v2',
|
'http://host.tld/?p1=v1&p2=v2',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/index.php',
|
'SCRIPT_NAME' => '/index.php',
|
||||||
'QUERY_STRING' => 'p1=v1&p2=v2'
|
'QUERY_STRING' => 'p1=v1&p2=v2'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/admin/?action=edit_tag',
|
'http://host.tld/admin/?action=edit_tag',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/index.php',
|
'SCRIPT_NAME' => '/admin/index.php',
|
||||||
'QUERY_STRING' => 'action=edit_tag'
|
'QUERY_STRING' => 'action=edit_tag'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -52,26 +53,26 @@ class PageUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/page.php?p1=v1&p2=v2',
|
'http://host.tld/page.php?p1=v1&p2=v2',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/page.php',
|
'SCRIPT_NAME' => '/page.php',
|
||||||
'QUERY_STRING' => 'p1=v1&p2=v2'
|
'QUERY_STRING' => 'p1=v1&p2=v2'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld/admin/page.php?action=edit_tag',
|
'http://host.tld/admin/page.php?action=edit_tag',
|
||||||
page_url(
|
page_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'SCRIPT_NAME' => '/admin/page.php',
|
'SCRIPT_NAME' => '/admin/page.php',
|
||||||
'QUERY_STRING' => 'action=edit_tag'
|
'QUERY_STRING' => 'action=edit_tag'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HttpUtils' tests
|
* HttpUtils' tests
|
||||||
*/
|
*/
|
||||||
|
@ -20,22 +21,22 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'ON',
|
'HTTPS' => 'ON',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '443'
|
'SERVER_PORT' => '443'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:8080',
|
'https://host.tld:8080',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'ON',
|
'HTTPS' => 'ON',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '8080'
|
'SERVER_PORT' => '8080'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -48,22 +49,22 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:8080',
|
'https://host.tld:8080',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||||
'HTTP_X_FORWARDED_PORT' => '8080',
|
'HTTP_X_FORWARDED_PORT' => '8080',
|
||||||
'HTTP_X_FORWARDED_HOST' => 'host.tld'
|
'HTTP_X_FORWARDED_HOST' => 'host.tld'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:4974',
|
'https://host.tld:4974',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https, https',
|
'HTTP_X_FORWARDED_PROTO' => 'https, https',
|
||||||
'HTTP_X_FORWARDED_PORT' => '4974, 80',
|
'HTTP_X_FORWARDED_PORT' => '4974, 80',
|
||||||
'HTTP_X_FORWARDED_HOST' => 'host.tld, example.com'
|
'HTTP_X_FORWARDED_HOST' => 'host.tld, example.com'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -76,51 +77,51 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:8080',
|
'https://host.tld:8080',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||||
'HTTP_X_FORWARDED_PORT' => '8080'
|
'HTTP_X_FORWARDED_PORT' => '8080'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https'
|
'HTTP_X_FORWARDED_PROTO' => 'https'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||||
'HTTP_X_FORWARDED_PORT' => '443'
|
'HTTP_X_FORWARDED_PORT' => '443'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:4974',
|
'https://host.tld:4974',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https, https',
|
'HTTP_X_FORWARDED_PROTO' => 'https, https',
|
||||||
'HTTP_X_FORWARDED_PORT' => '4974, 80'
|
'HTTP_X_FORWARDED_PORT' => '4974, 80'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -134,11 +135,11 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld:8080',
|
'http://host.tld:8080',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'OFF',
|
'HTTPS' => 'OFF',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '8080'
|
'SERVER_PORT' => '8080'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -146,11 +147,11 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld:8080',
|
'https://host.tld:8080',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'ON',
|
'HTTPS' => 'ON',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '8080'
|
'SERVER_PORT' => '8080'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -163,11 +164,11 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'http://host.tld',
|
'http://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'OFF',
|
'HTTPS' => 'OFF',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80'
|
'SERVER_PORT' => '80'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -180,11 +181,11 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'ON',
|
'HTTPS' => 'ON',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '443'
|
'SERVER_PORT' => '443'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -197,26 +198,26 @@ class ServerUrlTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'http',
|
'HTTP_X_FORWARDED_PROTO' => 'http',
|
||||||
'HTTP_X_FORWARDED_PORT' => '443'
|
'HTTP_X_FORWARDED_PORT' => '443'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'https://host.tld',
|
'https://host.tld',
|
||||||
server_url(
|
server_url(
|
||||||
array(
|
[
|
||||||
'HTTPS' => 'Off',
|
'HTTPS' => 'Off',
|
||||||
'SERVER_NAME' => 'host.tld',
|
'SERVER_NAME' => 'host.tld',
|
||||||
'SERVER_PORT' => '80',
|
'SERVER_PORT' => '80',
|
||||||
'HTTP_X_FORWARDED_PROTO' => 'https, http',
|
'HTTP_X_FORWARDED_PROTO' => 'https, http',
|
||||||
'HTTP_X_FORWARDED_PORT' => '443, 80'
|
'HTTP_X_FORWARDED_PORT' => '443, 80'
|
||||||
)
|
]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,12 @@ class MetadataRetrieverTest extends TestCase
|
||||||
->expects(static::once())
|
->expects(static::once())
|
||||||
->method('getCurlDownloadCallback')
|
->method('getCurlDownloadCallback')
|
||||||
->willReturnCallback(
|
->willReturnCallback(
|
||||||
function (&$charset, &$title, &$description, &$tags) use (
|
function (
|
||||||
|
&$charset,
|
||||||
|
&$title,
|
||||||
|
&$description,
|
||||||
|
&$tags
|
||||||
|
) use (
|
||||||
$remoteCharset,
|
$remoteCharset,
|
||||||
$remoteTitle,
|
$remoteTitle,
|
||||||
$remoteDesc,
|
$remoteDesc,
|
||||||
|
@ -95,7 +100,7 @@ class MetadataRetrieverTest extends TestCase
|
||||||
->expects(static::once())
|
->expects(static::once())
|
||||||
->method('getHttpResponse')
|
->method('getHttpResponse')
|
||||||
->with($url, 30, 4194304)
|
->with($url, 30, 4194304)
|
||||||
->willReturnCallback(function($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
|
->willReturnCallback(function ($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
|
||||||
$headerCallback();
|
$headerCallback();
|
||||||
$dlCallback();
|
$dlCallback();
|
||||||
})
|
})
|
||||||
|
@ -124,7 +129,8 @@ class MetadataRetrieverTest extends TestCase
|
||||||
->method('getCurlDownloadCallback')
|
->method('getCurlDownloadCallback')
|
||||||
->willReturnCallback(
|
->willReturnCallback(
|
||||||
function (): callable {
|
function (): callable {
|
||||||
return function (): void {};
|
return function (): void {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
@ -133,7 +139,8 @@ class MetadataRetrieverTest extends TestCase
|
||||||
->method('getCurlHeaderCallback')
|
->method('getCurlHeaderCallback')
|
||||||
->willReturnCallback(
|
->willReturnCallback(
|
||||||
function (): callable {
|
function (): callable {
|
||||||
return function (): void {};
|
return function (): void {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
|
@ -141,7 +148,7 @@ class MetadataRetrieverTest extends TestCase
|
||||||
->expects(static::once())
|
->expects(static::once())
|
||||||
->method('getHttpResponse')
|
->method('getHttpResponse')
|
||||||
->with($url, 30, 4194304)
|
->with($url, 30, 4194304)
|
||||||
->willReturnCallback(function($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
|
->willReturnCallback(function ($url, $timeout, $maxBytes, $headerCallback, $dlCallback): void {
|
||||||
$headerCallback();
|
$headerCallback();
|
||||||
$dlCallback();
|
$dlCallback();
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UrlUtils's tests
|
* UrlUtils's tests
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unitary tests for cleanup_url()
|
* Unitary tests for cleanup_url()
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +30,7 @@ class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
public function testCleanupUrlAlreadyClean()
|
public function testCleanupUrlAlreadyClean()
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref));
|
$this->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));
|
$this->assertEquals($this->ref2, cleanup_url($this->ref2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +39,9 @@ class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testCleanupUrlFragment()
|
public function testCleanupUrlFragment()
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'#tk.rss_all'));
|
$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-'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'#xtor=RSS-U3ht0tkc4b'));
|
$this->assertEquals($this->ref, cleanup_url($this->ref . '#xtor=RSS-U3ht0tkc4b'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,23 +49,23 @@ class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testCleanupUrlQuerySingle()
|
public function testCleanupUrlQuerySingle()
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?action_object_map=junk'));
|
$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_ref_map=Cr4p!'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?action_type_map=g4R84g3'));
|
$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_stuff=v41u3'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?fb=71m3w4573'));
|
$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_campaign=zomg'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_medium=numnum'));
|
$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_source=c0d3'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?utm_term=1n4l'));
|
$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_name=junk'));
|
||||||
$this->assertEquals($this->ref, cleanup_url($this->ref.'?campaign_start=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_item_index=junk'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,14 +73,14 @@ class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testCleanupUrlQueryMultiple()
|
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->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->assertEquals($this->ref, cleanup_url(
|
||||||
$this->ref.'?campaign_start=zomg&campaign_name=numnum'
|
$this->ref . '?campaign_start=zomg&campaign_name=numnum'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,22 +90,22 @@ class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
public function testCleanupUrlQueryFragment()
|
public function testCleanupUrlQueryFragment()
|
||||||
{
|
{
|
||||||
$this->assertEquals($this->ref, cleanup_url(
|
$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
|
// ditch annoying query params and fragment, keep useful params
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->ref.'?my=stuff&is=kept',
|
$this->ref . '?my=stuff&is=kept',
|
||||||
cleanup_url(
|
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
|
// ditch annoying query params, keep useful params and fragment
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$this->ref.'?my=stuff&is=kept#again',
|
$this->ref . '?my=stuff&is=kept#again',
|
||||||
cleanup_url(
|
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'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unitary tests for get_url_scheme()
|
* Unitary tests for get_url_scheme()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpares UrlUtils's tests
|
* Unpares UrlUtils's tests
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +18,7 @@ class UnparseUrlTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testUnparseEmptyArray()
|
public function testUnparseEmptyArray()
|
||||||
{
|
{
|
||||||
$this->assertEquals('', unparse_url(array()));
|
$this->assertEquals('', unparse_url([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +27,7 @@ class UnparseUrlTest extends \Shaarli\TestCase
|
||||||
public function testUnparseFull()
|
public function testUnparseFull()
|
||||||
{
|
{
|
||||||
$ref = 'http://username:password@hostname:9090/path'
|
$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)));
|
$this->assertEquals($ref, unparse_url(parse_url($ref)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WhitelistProtocolsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
$whitelist = ['ftp', 'magnet'];
|
$whitelist = ['ftp', 'magnet'];
|
||||||
$url = 'test.tld/path/?query=value#hash';
|
$url = 'test.tld/path/?query=value#hash';
|
||||||
$this->assertEquals('http://'. $url, whitelist_protocols($url, $whitelist));
|
$this->assertEquals('http://' . $url, whitelist_protocols($url, $whitelist));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'tests/bootstrap.php';
|
require_once 'tests/bootstrap.php';
|
||||||
|
|
||||||
if (! empty(getenv('UT_LOCALE'))) {
|
if (! empty(getenv('UT_LOCALE'))) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Shaarli;
|
namespace Shaarli;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Updater;
|
namespace Shaarli\Updater;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link datastore tests
|
* Link datastore tests
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +119,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
$this->assertFileNotExists(self::$testDatastore);
|
$this->assertFileNotExists(self::$testDatastore);
|
||||||
|
|
||||||
$checkDB = self::getMethod('check');
|
$checkDB = self::getMethod('check');
|
||||||
$checkDB->invokeArgs($linkDB, array());
|
$checkDB->invokeArgs($linkDB, []);
|
||||||
$this->assertFileExists(self::$testDatastore);
|
$this->assertFileExists(self::$testDatastore);
|
||||||
|
|
||||||
// ensure the correct data has been written
|
// ensure the correct data has been written
|
||||||
|
@ -135,7 +136,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
$this->assertGreaterThan(0, $datastoreSize);
|
$this->assertGreaterThan(0, $datastoreSize);
|
||||||
|
|
||||||
$checkDB = self::getMethod('check');
|
$checkDB = self::getMethod('check');
|
||||||
$checkDB->invokeArgs($linkDB, array());
|
$checkDB->invokeArgs($linkDB, []);
|
||||||
|
|
||||||
// ensure the datastore is left unmodified
|
// ensure the datastore is left unmodified
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -185,7 +186,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
$testDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$testDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
||||||
$dbSize = sizeof($testDB);
|
$dbSize = sizeof($testDB);
|
||||||
|
|
||||||
$link = array(
|
$link = [
|
||||||
'id' => 43,
|
'id' => 43,
|
||||||
'title' => 'an additional link',
|
'title' => 'an additional link',
|
||||||
'url' => 'http://dum.my',
|
'url' => 'http://dum.my',
|
||||||
|
@ -193,7 +194,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
'private' => 0,
|
'private' => 0,
|
||||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150518_190000'),
|
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150518_190000'),
|
||||||
'tags' => 'unit test'
|
'tags' => 'unit test'
|
||||||
);
|
];
|
||||||
$testDB[$link['id']] = $link;
|
$testDB[$link['id']] = $link;
|
||||||
$testDB->save('tests');
|
$testDB->save('tests');
|
||||||
|
|
||||||
|
@ -239,12 +240,12 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
public function testDays()
|
public function testDays()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('20100309', '20100310', '20121206', '20121207', '20130614', '20150310'),
|
['20100309', '20100310', '20121206', '20121207', '20130614', '20150310'],
|
||||||
self::$publicLinkDB->days()
|
self::$publicLinkDB->days()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('20100309', '20100310', '20121206', '20121207', '20130614', '20141125', '20150310'),
|
['20100309', '20100310', '20121206', '20121207', '20130614', '20141125', '20150310'],
|
||||||
self::$privateLinkDB->days()
|
self::$privateLinkDB->days()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +281,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
public function testAllTags()
|
public function testAllTags()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
[
|
||||||
'web' => 3,
|
'web' => 3,
|
||||||
'cartoon' => 2,
|
'cartoon' => 2,
|
||||||
'gnu' => 2,
|
'gnu' => 2,
|
||||||
|
@ -300,12 +301,12 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
'coding-style' => 1,
|
'coding-style' => 1,
|
||||||
'quality' => 1,
|
'quality' => 1,
|
||||||
'standards' => 1,
|
'standards' => 1,
|
||||||
),
|
],
|
||||||
self::$publicLinkDB->linksCountPerTag()
|
self::$publicLinkDB->linksCountPerTag()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
[
|
||||||
'web' => 4,
|
'web' => 4,
|
||||||
'cartoon' => 3,
|
'cartoon' => 3,
|
||||||
'gnu' => 2,
|
'gnu' => 2,
|
||||||
|
@ -332,11 +333,11 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
'coding-style' => 1,
|
'coding-style' => 1,
|
||||||
'quality' => 1,
|
'quality' => 1,
|
||||||
'standards' => 1,
|
'standards' => 1,
|
||||||
),
|
],
|
||||||
self::$privateLinkDB->linksCountPerTag()
|
self::$privateLinkDB->linksCountPerTag()
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
[
|
||||||
'web' => 4,
|
'web' => 4,
|
||||||
'cartoon' => 2,
|
'cartoon' => 2,
|
||||||
'gnu' => 1,
|
'gnu' => 1,
|
||||||
|
@ -349,17 +350,17 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
'Mercurial' => 1,
|
'Mercurial' => 1,
|
||||||
'.hidden' => 1,
|
'.hidden' => 1,
|
||||||
'hashtag' => 1,
|
'hashtag' => 1,
|
||||||
),
|
],
|
||||||
self::$privateLinkDB->linksCountPerTag(['web'])
|
self::$privateLinkDB->linksCountPerTag(['web'])
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
[
|
||||||
'web' => 1,
|
'web' => 1,
|
||||||
'html' => 1,
|
'html' => 1,
|
||||||
'w3c' => 1,
|
'w3c' => 1,
|
||||||
'css' => 1,
|
'css' => 1,
|
||||||
'Mercurial' => 1,
|
'Mercurial' => 1,
|
||||||
),
|
],
|
||||||
self::$privateLinkDB->linksCountPerTag(['web'], 'private')
|
self::$privateLinkDB->linksCountPerTag(['web'], 'private')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -370,7 +371,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
public function testFilterString()
|
public function testFilterString()
|
||||||
{
|
{
|
||||||
$tags = 'dev cartoon';
|
$tags = 'dev cartoon';
|
||||||
$request = array('searchtags' => $tags);
|
$request = ['searchtags' => $tags];
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
2,
|
2,
|
||||||
count(self::$privateLinkDB->filterSearch($request, true, false))
|
count(self::$privateLinkDB->filterSearch($request, true, false))
|
||||||
|
@ -382,8 +383,8 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testFilterArray()
|
public function testFilterArray()
|
||||||
{
|
{
|
||||||
$tags = array('dev', 'cartoon');
|
$tags = ['dev', 'cartoon'];
|
||||||
$request = array('searchtags' => $tags);
|
$request = ['searchtags' => $tags];
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
2,
|
2,
|
||||||
count(self::$privateLinkDB->filterSearch($request, true, false))
|
count(self::$privateLinkDB->filterSearch($request, true, false))
|
||||||
|
@ -397,7 +398,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
public function testHiddenTags()
|
public function testHiddenTags()
|
||||||
{
|
{
|
||||||
$tags = '.hidden';
|
$tags = '.hidden';
|
||||||
$request = array('searchtags' => $tags);
|
$request = ['searchtags' => $tags];
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
count(self::$privateLinkDB->filterSearch($request, true, false))
|
count(self::$privateLinkDB->filterSearch($request, true, false))
|
||||||
|
@ -639,7 +640,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
for ($i = 0; $i < 4; ++$i) {
|
for ($i = 0; $i < 4; ++$i) {
|
||||||
$linkDB[$nextId + $i] = [
|
$linkDB[$nextId + $i] = [
|
||||||
'id' => $nextId + $i,
|
'id' => $nextId + $i,
|
||||||
'url' => 'http://'. $i,
|
'url' => 'http://' . $i,
|
||||||
'created' => $creation,
|
'created' => $creation,
|
||||||
'title' => true,
|
'title' => true,
|
||||||
'description' => true,
|
'description' => true,
|
||||||
|
@ -657,7 +658,7 @@ class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->assertEquals($nextId + $count, $link['id']);
|
$this->assertEquals($nextId + $count, $link['id']);
|
||||||
$this->assertEquals('http://'. $count, $link['url']);
|
$this->assertEquals('http://' . $count, $link['url']);
|
||||||
if (--$count < 0) {
|
if (--$count < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,28 +450,28 @@ class LegacyLinkFilterTest extends \Shaarli\TestCase
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
||||||
array($tags, $terms)
|
[$tags, $terms]
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
2,
|
2,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
||||||
array('', $terms)
|
['', $terms]
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
||||||
array(false, 'PSR-2')
|
[false, 'PSR-2']
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
1,
|
1,
|
||||||
count(self::$linkFilter->filter(
|
count(self::$linkFilter->filter(
|
||||||
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
LegacyLinkFilter::$FILTER_TAG | LegacyLinkFilter::$FILTER_TEXT,
|
||||||
array($tags, '')
|
[$tags, '']
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Updater;
|
namespace Shaarli\Updater;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
@ -42,7 +43,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
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->conf = new ConfigManager(self::$configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +52,10 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testReadEmptyUpdatesFile()
|
public function testReadEmptyUpdatesFile()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
|
$this->assertEquals([], UpdaterUtils::readUpdatesFile(''));
|
||||||
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
||||||
touch($updatesFile);
|
touch($updatesFile);
|
||||||
$this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
|
$this->assertEquals([], UpdaterUtils::readUpdatesFile($updatesFile));
|
||||||
unlink($updatesFile);
|
unlink($updatesFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
public function testReadWriteUpdatesFile()
|
public function testReadWriteUpdatesFile()
|
||||||
{
|
{
|
||||||
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
||||||
$updatesMethods = array('m1', 'm2', 'm3');
|
$updatesMethods = ['m1', 'm2', 'm3'];
|
||||||
|
|
||||||
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
|
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
|
||||||
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
|
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
|
||||||
|
@ -86,7 +87,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
||||||
|
|
||||||
UpdaterUtils::writeUpdatesFile('', array('test'));
|
UpdaterUtils::writeUpdatesFile('', ['test']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +102,7 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
touch($updatesFile);
|
touch($updatesFile);
|
||||||
chmod($updatesFile, 0444);
|
chmod($updatesFile, 0444);
|
||||||
try {
|
try {
|
||||||
@UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
|
@UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
unlink($updatesFile);
|
unlink($updatesFile);
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -115,17 +116,17 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testNoUpdates()
|
public function testNoUpdates()
|
||||||
{
|
{
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
'updateMethodException',
|
'updateMethodException',
|
||||||
);
|
];
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$this->assertEquals(array(), $updater->update());
|
$this->assertEquals([], $updater->update());
|
||||||
|
|
||||||
$updater = new DummyUpdater(array(), array(), $this->conf, false);
|
$updater = new DummyUpdater([], [], $this->conf, false);
|
||||||
$this->assertEquals(array(), $updater->update());
|
$this->assertEquals([], $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,13 +134,13 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testUpdatesFirstTime()
|
public function testUpdatesFirstTime()
|
||||||
{
|
{
|
||||||
$updates = array('updateMethodException',);
|
$updates = ['updateMethodException',];
|
||||||
$expectedUpdates = array(
|
$expectedUpdates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
);
|
];
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$this->assertEquals($expectedUpdates, $updater->update());
|
$this->assertEquals($expectedUpdates, $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,14 +149,14 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
*/
|
*/
|
||||||
public function testOneUpdate()
|
public function testOneUpdate()
|
||||||
{
|
{
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
'updateMethodException',
|
'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());
|
$this->assertEquals($expectedUpdate, $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +167,13 @@ class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
|
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
);
|
];
|
||||||
|
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$updater->update();
|
$updater->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +198,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$this->conf->setConfigFile('tests/updater/config');
|
$this->conf->setConfigFile('tests/updater/config');
|
||||||
|
|
||||||
// merge configs
|
// 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
|
// This writes a new config file in tests/updater/config.php
|
||||||
$updater->updateMethodMergeDeprecatedConfigFile();
|
$updater->updateMethodMergeDeprecatedConfigFile();
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
*/
|
*/
|
||||||
public function testMergeDeprecatedConfigNoFile()
|
public function testMergeDeprecatedConfigNoFile()
|
||||||
{
|
{
|
||||||
$updater = new LegacyUpdater(array(), array(), $this->conf, true);
|
$updater = new LegacyUpdater([], [], $this->conf, true);
|
||||||
$updater->updateMethodMergeDeprecatedConfigFile();
|
$updater->updateMethodMergeDeprecatedConfigFile();
|
||||||
|
|
||||||
$this->assertEquals('root', $this->conf->get('credentials.login'));
|
$this->assertEquals('root', $this->conf->get('credentials.login'));
|
||||||
|
@ -229,10 +230,10 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$refDB->write(self::$testDatastore);
|
$refDB->write(self::$testDatastore);
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
||||||
|
|
||||||
$this->assertEmpty($linkDB->filterSearch(array('searchtags' => 'exclude')));
|
$this->assertEmpty($linkDB->filterSearch(['searchtags' => 'exclude']));
|
||||||
$updater = new LegacyUpdater(array(), $linkDB, $this->conf, true);
|
$updater = new LegacyUpdater([], $linkDB, $this->conf, true);
|
||||||
$updater->updateMethodRenameDashTags();
|
$updater->updateMethodRenameDashTags();
|
||||||
$this->assertNotEmpty($linkDB->filterSearch(array('searchtags' => 'exclude')));
|
$this->assertNotEmpty($linkDB->filterSearch(['searchtags' => 'exclude']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +248,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
// The ConfigIO is initialized with ConfigPhp.
|
// The ConfigIO is initialized with ConfigPhp.
|
||||||
$this->assertTrue($this->conf->getConfigIO() instanceof 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();
|
$done = $updater->updateMethodConfigToJson();
|
||||||
$this->assertTrue($done);
|
$this->assertTrue($done);
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
public function testConfigToJsonNothingToDo()
|
public function testConfigToJsonNothingToDo()
|
||||||
{
|
{
|
||||||
$filetime = filemtime($this->conf->getConfigFileExt());
|
$filetime = filemtime($this->conf->getConfigFileExt());
|
||||||
$updater = new LegacyUpdater(array(), array(), $this->conf, false);
|
$updater = new LegacyUpdater([], [], $this->conf, false);
|
||||||
$done = $updater->updateMethodConfigToJson();
|
$done = $updater->updateMethodConfigToJson();
|
||||||
$this->assertTrue($done);
|
$this->assertTrue($done);
|
||||||
$expected = filemtime($this->conf->getConfigFileExt());
|
$expected = filemtime($this->conf->getConfigFileExt());
|
||||||
|
@ -291,7 +292,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$headerLink = '<script>alert("header_link");</script>';
|
$headerLink = '<script>alert("header_link");</script>';
|
||||||
$this->conf->set('general.title', $title);
|
$this->conf->set('general.title', $title);
|
||||||
$this->conf->set('general.header_link', $headerLink);
|
$this->conf->set('general.header_link', $headerLink);
|
||||||
$updater = new LegacyUpdater(array(), array(), $this->conf, true);
|
$updater = new LegacyUpdater([], [], $this->conf, true);
|
||||||
$done = $updater->updateMethodEscapeUnescapedConfig();
|
$done = $updater->updateMethodEscapeUnescapedConfig();
|
||||||
$this->assertTrue($done);
|
$this->assertTrue($done);
|
||||||
$this->conf->reload();
|
$this->conf->reload();
|
||||||
|
@ -306,9 +307,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
public function testUpdateApiSettings()
|
public function testUpdateApiSettings()
|
||||||
{
|
{
|
||||||
$confFile = 'sandbox/config';
|
$confFile = 'sandbox/config';
|
||||||
copy(self::$configFile .'.json.php', $confFile .'.json.php');
|
copy(self::$configFile . '.json.php', $confFile . '.json.php');
|
||||||
$conf = new ConfigManager($confFile);
|
$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.enabled'));
|
||||||
$this->assertFalse($conf->exists('api.secret'));
|
$this->assertFalse($conf->exists('api.secret'));
|
||||||
|
@ -316,7 +317,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$conf->reload();
|
$conf->reload();
|
||||||
$this->assertTrue($conf->get('api.enabled'));
|
$this->assertTrue($conf->get('api.enabled'));
|
||||||
$this->assertTrue($conf->exists('api.secret'));
|
$this->assertTrue($conf->exists('api.secret'));
|
||||||
unlink($confFile .'.json.php');
|
unlink($confFile . '.json.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,15 +326,15 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
public function testUpdateApiSettingsNothingToDo()
|
public function testUpdateApiSettingsNothingToDo()
|
||||||
{
|
{
|
||||||
$confFile = 'sandbox/config';
|
$confFile = 'sandbox/config';
|
||||||
copy(self::$configFile .'.json.php', $confFile .'.json.php');
|
copy(self::$configFile . '.json.php', $confFile . '.json.php');
|
||||||
$conf = new ConfigManager($confFile);
|
$conf = new ConfigManager($confFile);
|
||||||
$conf->set('api.enabled', false);
|
$conf->set('api.enabled', false);
|
||||||
$conf->set('api.secret', '');
|
$conf->set('api.secret', '');
|
||||||
$updater = new LegacyUpdater(array(), array(), $conf, true);
|
$updater = new LegacyUpdater([], [], $conf, true);
|
||||||
$updater->updateMethodApiSettings();
|
$updater->updateMethodApiSettings();
|
||||||
$this->assertFalse($conf->get('api.enabled'));
|
$this->assertFalse($conf->get('api.enabled'));
|
||||||
$this->assertEmpty($conf->get('api.secret'));
|
$this->assertEmpty($conf->get('api.secret'));
|
||||||
unlink($confFile .'.json.php');
|
unlink($confFile . '.json.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -341,8 +342,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
*/
|
*/
|
||||||
public function testDatastoreIds()
|
public function testDatastoreIds()
|
||||||
{
|
{
|
||||||
$links = array(
|
$links = [
|
||||||
'20121206_182539' => array(
|
'20121206_182539' => [
|
||||||
'linkdate' => '20121206_182539',
|
'linkdate' => '20121206_182539',
|
||||||
'title' => 'Geek and Poke',
|
'title' => 'Geek and Poke',
|
||||||
'url' => 'http://geek-and-poke.com/',
|
'url' => 'http://geek-and-poke.com/',
|
||||||
|
@ -350,24 +351,24 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
'tags' => 'dev cartoon tag1 tag2 tag3 tag4 ',
|
'tags' => 'dev cartoon tag1 tag2 tag3 tag4 ',
|
||||||
'updated' => '20121206_190301',
|
'updated' => '20121206_190301',
|
||||||
'private' => false,
|
'private' => false,
|
||||||
),
|
],
|
||||||
'20121206_172539' => array(
|
'20121206_172539' => [
|
||||||
'linkdate' => '20121206_172539',
|
'linkdate' => '20121206_172539',
|
||||||
'title' => 'UserFriendly - Samba',
|
'title' => 'UserFriendly - Samba',
|
||||||
'url' => 'http://ars.userfriendly.org/cartoons/?id=20010306',
|
'url' => 'http://ars.userfriendly.org/cartoons/?id=20010306',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'tags' => 'samba cartoon web',
|
'tags' => 'samba cartoon web',
|
||||||
'private' => false,
|
'private' => false,
|
||||||
),
|
],
|
||||||
'20121206_142300' => array(
|
'20121206_142300' => [
|
||||||
'linkdate' => '20121206_142300',
|
'linkdate' => '20121206_142300',
|
||||||
'title' => 'UserFriendly - Web Designer',
|
'title' => 'UserFriendly - Web Designer',
|
||||||
'url' => 'http://ars.userfriendly.org/cartoons/?id=20121206',
|
'url' => 'http://ars.userfriendly.org/cartoons/?id=20121206',
|
||||||
'description' => 'Naming conventions... #private',
|
'description' => 'Naming conventions... #private',
|
||||||
'tags' => 'samba cartoon web',
|
'tags' => 'samba cartoon web',
|
||||||
'private' => true,
|
'private' => true,
|
||||||
),
|
],
|
||||||
);
|
];
|
||||||
$refDB = new \ReferenceLinkDB(true);
|
$refDB = new \ReferenceLinkDB(true);
|
||||||
$refDB->setLinks($links);
|
$refDB->setLinks($links);
|
||||||
$refDB->write(self::$testDatastore);
|
$refDB->write(self::$testDatastore);
|
||||||
|
@ -378,12 +379,12 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$this->conf->set('resource.data_dir', 'sandbox');
|
$this->conf->set('resource.data_dir', 'sandbox');
|
||||||
$this->conf->set('resource.datastore', self::$testDatastore);
|
$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());
|
$this->assertTrue($updater->updateMethodDatastoreIds());
|
||||||
|
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$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;
|
$backup = null;
|
||||||
foreach ($backupFiles as $backupFile) {
|
foreach ($backupFiles as $backupFile) {
|
||||||
if (strpos($backupFile, '_1') === false) {
|
if (strpos($backupFile, '_1') === false) {
|
||||||
|
@ -445,7 +446,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$this->conf->set('resource.datastore', self::$testDatastore);
|
$this->conf->set('resource.datastore', self::$testDatastore);
|
||||||
|
|
||||||
$checksum = hash_file('sha1', 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->assertTrue($updater->updateMethodDatastoreIds());
|
||||||
$this->assertEquals($checksum, hash_file('sha1', self::$testDatastore));
|
$this->assertEquals($checksum, hash_file('sha1', self::$testDatastore));
|
||||||
}
|
}
|
||||||
|
@ -478,9 +479,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$sandbox = 'sandbox/config';
|
$sandbox = 'sandbox/config';
|
||||||
copy(self::$configFile . '.json.php', $sandbox . '.json.php');
|
copy(self::$configFile . '.json.php', $sandbox . '.json.php');
|
||||||
$this->conf = new ConfigManager($sandbox);
|
$this->conf = new ConfigManager($sandbox);
|
||||||
mkdir('sandbox/'. $theme);
|
mkdir('sandbox/' . $theme);
|
||||||
touch('sandbox/'. $theme .'/linklist.html');
|
touch('sandbox/' . $theme . '/linklist.html');
|
||||||
$this->conf->set('resource.raintpl_tpl', 'sandbox/'. $theme .'/');
|
$this->conf->set('resource.raintpl_tpl', 'sandbox/' . $theme . '/');
|
||||||
$updater = new LegacyUpdater([], [], $this->conf, true);
|
$updater = new LegacyUpdater([], [], $this->conf, true);
|
||||||
$this->assertTrue($updater->updateMethodDefaultTheme());
|
$this->assertTrue($updater->updateMethodDefaultTheme());
|
||||||
|
|
||||||
|
@ -490,8 +491,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$this->assertEquals('sandbox', $this->conf->get('resource.raintpl_tpl'));
|
$this->assertEquals('sandbox', $this->conf->get('resource.raintpl_tpl'));
|
||||||
$this->assertEquals($theme, $this->conf->get('resource.theme'));
|
$this->assertEquals($theme, $this->conf->get('resource.theme'));
|
||||||
unlink($sandbox . '.json.php');
|
unlink($sandbox . '.json.php');
|
||||||
unlink('sandbox/'. $theme .'/linklist.html');
|
unlink('sandbox/' . $theme . '/linklist.html');
|
||||||
rmdir('sandbox/'. $theme);
|
rmdir('sandbox/' . $theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -572,11 +573,11 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$this->conf->set('plugins.PIWIK_URL', $url);
|
$this->conf->set('plugins.PIWIK_URL', $url);
|
||||||
$updater = new LegacyUpdater([], [], $this->conf, true);
|
$updater = new LegacyUpdater([], [], $this->conf, true);
|
||||||
$this->assertTrue($updater->updateMethodPiwikUrl());
|
$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
|
// reload from file
|
||||||
$this->conf = new ConfigManager($sandboxConf);
|
$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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -786,7 +787,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$refDB->write(self::$testDatastore);
|
$refDB->write(self::$testDatastore);
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$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());
|
$this->assertTrue($updater->updateMethodSetSticky());
|
||||||
|
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
||||||
|
@ -817,7 +818,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
||||||
$refDB->write(self::$testDatastore);
|
$refDB->write(self::$testDatastore);
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$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());
|
$this->assertTrue($updater->updateMethodSetSticky());
|
||||||
|
|
||||||
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
$linkDB = new LegacyLinkDB(self::$testDatastore, true, false);
|
||||||
|
|
|
@ -135,7 +135,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('empty.htm');
|
$files = file2array('empty.htm');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'File empty.htm (0 bytes) has an unknown file format.'
|
'File empty.htm (0 bytes) has an unknown file format.'
|
||||||
.' Nothing was imported.',
|
. ' Nothing was imported.',
|
||||||
$this->netscapeBookmarkUtils->import(null, $files)
|
$this->netscapeBookmarkUtils->import(null, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(0, $this->bookmarkService->count());
|
$this->assertEquals(0, $this->bookmarkService->count());
|
||||||
|
@ -162,7 +162,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('lowercase_doctype.htm');
|
$files = file2array('lowercase_doctype.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File lowercase_doctype.htm (386 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import(null, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -177,7 +177,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('internet_explorer_encoding.htm');
|
$files = file2array('internet_explorer_encoding.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File internet_explorer_encoding.htm (356 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import([], $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(1, $this->bookmarkService->count());
|
$this->assertEquals(1, $this->bookmarkService->count());
|
||||||
|
@ -205,7 +205,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('netscape_nested.htm');
|
$files = file2array('netscape_nested.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_nested.htm (1337 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import([], $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(8, $this->bookmarkService->count());
|
$this->assertEquals(8, $this->bookmarkService->count());
|
||||||
|
@ -326,7 +326,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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)
|
$this->netscapeBookmarkUtils->import([], $files)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -365,11 +365,11 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testImportKeepPrivacy()
|
public function testImportKeepPrivacy()
|
||||||
{
|
{
|
||||||
$post = array('privacy' => 'default');
|
$post = ['privacy' => 'default'];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -408,11 +408,11 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testImportAsPublic()
|
public function testImportAsPublic()
|
||||||
{
|
{
|
||||||
$post = array('privacy' => 'public');
|
$post = ['privacy' => 'public'];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -426,11 +426,11 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testImportAsPrivate()
|
public function testImportAsPrivate()
|
||||||
{
|
{
|
||||||
$post = array('privacy' => 'private');
|
$post = ['privacy' => 'private'];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -447,10 +447,10 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
|
|
||||||
// import bookmarks as private
|
// import bookmarks as private
|
||||||
$post = array('privacy' => 'private');
|
$post = ['privacy' => 'private'];
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -459,13 +459,13 @@ class BookmarkImportTest extends TestCase
|
||||||
$this->assertTrue($this->bookmarkService->get(1)->isPrivate());
|
$this->assertTrue($this->bookmarkService->get(1)->isPrivate());
|
||||||
|
|
||||||
// re-import as public, enable overwriting
|
// re-import as public, enable overwriting
|
||||||
$post = array(
|
$post = [
|
||||||
'privacy' => 'public',
|
'privacy' => 'public',
|
||||||
'overwrite' => 'true'
|
'overwrite' => 'true'
|
||||||
);
|
];
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -482,10 +482,10 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
|
|
||||||
// import bookmarks as public
|
// import bookmarks as public
|
||||||
$post = array('privacy' => 'public');
|
$post = ['privacy' => 'public'];
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -494,13 +494,13 @@ class BookmarkImportTest extends TestCase
|
||||||
$this->assertFalse($this->bookmarkService->get(1)->isPrivate());
|
$this->assertFalse($this->bookmarkService->get(1)->isPrivate());
|
||||||
|
|
||||||
// re-import as private, enable overwriting
|
// re-import as private, enable overwriting
|
||||||
$post = array(
|
$post = [
|
||||||
'privacy' => 'private',
|
'privacy' => 'private',
|
||||||
'overwrite' => 'true'
|
'overwrite' => 'true'
|
||||||
);
|
];
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -514,21 +514,21 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testSkipOverwrite()
|
public function testSkipOverwrite()
|
||||||
{
|
{
|
||||||
$post = array('privacy' => 'public');
|
$post = ['privacy' => 'public'];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
||||||
|
|
||||||
// re-import as private, DO NOT enable overwriting
|
// re-import as private, DO NOT enable overwriting
|
||||||
$post = array('privacy' => 'private');
|
$post = ['privacy' => 'private'];
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -540,14 +540,14 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testSetDefaultTags()
|
public function testSetDefaultTags()
|
||||||
{
|
{
|
||||||
$post = array(
|
$post = [
|
||||||
'privacy' => 'public',
|
'privacy' => 'public',
|
||||||
'default_tags' => 'tag1 tag2 tag3'
|
'default_tags' => 'tag1 tag2 tag3'
|
||||||
);
|
];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -561,14 +561,14 @@ class BookmarkImportTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testSanitizeDefaultTags()
|
public function testSanitizeDefaultTags()
|
||||||
{
|
{
|
||||||
$post = array(
|
$post = [
|
||||||
'privacy' => 'public',
|
'privacy' => 'public',
|
||||||
'default_tags' => 'tag1& tag2 "tag3"'
|
'default_tags' => 'tag1& tag2 "tag3"'
|
||||||
);
|
];
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -597,7 +597,7 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('netscape_basic.htm');
|
$files = file2array('netscape_basic.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File netscape_basic.htm (482 bytes) was successfully processed in %d seconds:'
|
'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->netscapeBookmarkUtils->import($post, $files)
|
||||||
);
|
);
|
||||||
$this->assertEquals(2, $this->bookmarkService->count());
|
$this->assertEquals(2, $this->bookmarkService->count());
|
||||||
|
@ -630,8 +630,8 @@ class BookmarkImportTest extends TestCase
|
||||||
$files = file2array('same_date.htm');
|
$files = file2array('same_date.htm');
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
|
'File same_date.htm (453 bytes) was successfully processed in %d seconds:'
|
||||||
.' 3 bookmarks imported, 0 bookmarks overwritten, 0 bookmarks skipped.',
|
. ' 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(3, $this->bookmarkService->count());
|
||||||
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
$this->assertEquals(0, $this->bookmarkService->count(BookmarkFilter::$PRIVATE));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Addlink;
|
namespace Shaarli\Plugin\Addlink;
|
||||||
|
|
||||||
use Shaarli\Plugin\PluginManager;
|
use Shaarli\Plugin\PluginManager;
|
||||||
|
@ -25,7 +26,7 @@ class PluginAddlinkTest extends \Shaarli\TestCase
|
||||||
public function testAddlinkHeaderLoggedIn()
|
public function testAddlinkHeaderLoggedIn()
|
||||||
{
|
{
|
||||||
$str = 'stuff';
|
$str = 'stuff';
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||||
$data['_LOGGEDIN_'] = true;
|
$data['_LOGGEDIN_'] = true;
|
||||||
$data['_BASE_PATH_'] = '/subfolder';
|
$data['_BASE_PATH_'] = '/subfolder';
|
||||||
|
@ -34,7 +35,7 @@ class PluginAddlinkTest extends \Shaarli\TestCase
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertEquals(1, count($data['fields_toolbar']));
|
$this->assertEquals(1, count($data['fields_toolbar']));
|
||||||
|
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = $str;
|
$data['_PAGE_'] = $str;
|
||||||
$data['_LOGGEDIN_'] = true;
|
$data['_LOGGEDIN_'] = true;
|
||||||
$data['_BASE_PATH_'] = '/subfolder';
|
$data['_BASE_PATH_'] = '/subfolder';
|
||||||
|
@ -50,7 +51,7 @@ class PluginAddlinkTest extends \Shaarli\TestCase
|
||||||
public function testAddlinkHeaderLoggedOut()
|
public function testAddlinkHeaderLoggedOut()
|
||||||
{
|
{
|
||||||
$str = 'stuff';
|
$str = 'stuff';
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||||
$data['_LOGGEDIN_'] = false;
|
$data['_LOGGEDIN_'] = false;
|
||||||
$data['_BASE_PATH_'] = '/subfolder';
|
$data['_BASE_PATH_'] = '/subfolder';
|
||||||
|
|
|
@ -47,16 +47,16 @@ class PluginArchiveorgTest extends TestCase
|
||||||
{
|
{
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
|
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'url' => $str,
|
'url' => $str,
|
||||||
'private' => 0,
|
'private' => 0,
|
||||||
'real_url' => $str
|
'real_url' => $str
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$data = hook_archiveorg_render_linklist($data);
|
$data = hook_archiveorg_render_linklist($data);
|
||||||
|
|
||||||
|
@ -84,41 +84,41 @@ class PluginArchiveorgTest extends TestCase
|
||||||
$internalLink3 = 'http://shaarli.shaarli/shaare/z7u-_Q';
|
$internalLink3 = 'http://shaarli.shaarli/shaare/z7u-_Q';
|
||||||
$internalLinkRealURL3 = '/shaare/z7u-_Q';
|
$internalLinkRealURL3 = '/shaare/z7u-_Q';
|
||||||
|
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $internalLink1,
|
'title' => $internalLink1,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'url' => $internalLink1,
|
'url' => $internalLink1,
|
||||||
'private' => 0,
|
'private' => 0,
|
||||||
'real_url' => $internalLinkRealURL1
|
'real_url' => $internalLinkRealURL1
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'url' => $internalLink1,
|
'url' => $internalLink1,
|
||||||
'private' => 1,
|
'private' => 1,
|
||||||
'real_url' => $internalLinkRealURL1
|
'real_url' => $internalLinkRealURL1
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'url' => $internalLink2,
|
'url' => $internalLink2,
|
||||||
'private' => 0,
|
'private' => 0,
|
||||||
'real_url' => $internalLinkRealURL2
|
'real_url' => $internalLinkRealURL2
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'url' => $internalLink2,
|
'url' => $internalLink2,
|
||||||
'private' => 1,
|
'private' => 1,
|
||||||
'real_url' => $internalLinkRealURL2
|
'real_url' => $internalLinkRealURL2
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'url' => $internalLink3,
|
'url' => $internalLink3,
|
||||||
'private' => 0,
|
'private' => 0,
|
||||||
'real_url' => $internalLinkRealURL3
|
'real_url' => $internalLinkRealURL3
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'url' => $internalLink3,
|
'url' => $internalLink3,
|
||||||
'private' => 1,
|
'private' => 1,
|
||||||
'real_url' => $internalLinkRealURL3
|
'real_url' => $internalLinkRealURL3
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$data = hook_archiveorg_render_linklist($data);
|
$data = hook_archiveorg_render_linklist($data);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Isso;
|
namespace Shaarli\Plugin\Isso;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
@ -55,16 +56,16 @@ class PluginIssoTest extends TestCase
|
||||||
|
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$date = '20161118_100001';
|
$date = '20161118_100001';
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'id' => 12,
|
'id' => 12,
|
||||||
'url' => $str,
|
'url' => $str,
|
||||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
|
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$data = hook_isso_render_linklist($data, $conf);
|
$data = hook_isso_render_linklist($data, $conf);
|
||||||
|
|
||||||
|
@ -76,11 +77,11 @@ class PluginIssoTest extends TestCase
|
||||||
$this->assertEquals(1, count($data['plugin_end_zone']));
|
$this->assertEquals(1, count($data['plugin_end_zone']));
|
||||||
$this->assertNotFalse(strpos(
|
$this->assertNotFalse(strpos(
|
||||||
$data['plugin_end_zone'][0],
|
$data['plugin_end_zone'][0],
|
||||||
'data-isso-id="'. $data['links'][0]['id'] .'"'
|
'data-isso-id="' . $data['links'][0]['id'] . '"'
|
||||||
));
|
));
|
||||||
$this->assertNotFalse(strpos(
|
$this->assertNotFalse(strpos(
|
||||||
$data['plugin_end_zone'][0],
|
$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'));
|
$this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js'));
|
||||||
}
|
}
|
||||||
|
@ -96,28 +97,28 @@ class PluginIssoTest extends TestCase
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$date1 = '20161118_100001';
|
$date1 = '20161118_100001';
|
||||||
$date2 = '20161118_100002';
|
$date2 = '20161118_100002';
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'id' => 12,
|
'id' => 12,
|
||||||
'url' => $str,
|
'url' => $str,
|
||||||
'shorturl' => $short1 = 'abcd',
|
'shorturl' => $short1 = 'abcd',
|
||||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date1),
|
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date1),
|
||||||
),
|
],
|
||||||
array(
|
[
|
||||||
'id' => 13,
|
'id' => 13,
|
||||||
'url' => $str . '2',
|
'url' => $str . '2',
|
||||||
'shorturl' => $short2 = 'efgh',
|
'shorturl' => $short2 = 'efgh',
|
||||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date2),
|
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date2),
|
||||||
),
|
],
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$processed = hook_isso_render_linklist($data, $conf);
|
$processed = hook_isso_render_linklist($data, $conf);
|
||||||
// link_plugin should be added for the icon
|
// link_plugin should be added for the icon
|
||||||
$this->assertContainsPolyfill('<a href="/shaare/'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
|
$this->assertContainsPolyfill('<a href="/shaare/' . $short1 . '#isso-thread">', $processed['links'][0]['link_plugin'][0]);
|
||||||
$this->assertContainsPolyfill('<a href="/shaare/'. $short2 .'#isso-thread">', $processed['links'][1]['link_plugin'][0]);
|
$this->assertContainsPolyfill('<a href="/shaare/' . $short2 . '#isso-thread">', $processed['links'][1]['link_plugin'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,23 +131,23 @@ class PluginIssoTest extends TestCase
|
||||||
|
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$date = '20161118_100001';
|
$date = '20161118_100001';
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'id' => 12,
|
'id' => 12,
|
||||||
'url' => $str,
|
'url' => $str,
|
||||||
'shorturl' => $short1 = 'abcd',
|
'shorturl' => $short1 = 'abcd',
|
||||||
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
|
'created' => DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, $date),
|
||||||
)
|
]
|
||||||
),
|
],
|
||||||
'search_term' => $str
|
'search_term' => $str
|
||||||
);
|
];
|
||||||
|
|
||||||
$processed = hook_isso_render_linklist($data, $conf);
|
$processed = hook_isso_render_linklist($data, $conf);
|
||||||
|
|
||||||
// link_plugin should be added for the icon
|
// link_plugin should be added for the icon
|
||||||
$this->assertContainsPolyfill('<a href="/shaare/'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
|
$this->assertContainsPolyfill('<a href="/shaare/' . $short1 . '#isso-thread">', $processed['links'][0]['link_plugin'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Playvideos;
|
namespace Shaarli\Plugin\Playvideos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,14 +31,14 @@ class PluginPlayvideosTest extends \Shaarli\TestCase
|
||||||
public function testPlayvideosHeader()
|
public function testPlayvideosHeader()
|
||||||
{
|
{
|
||||||
$str = 'stuff';
|
$str = 'stuff';
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||||
|
|
||||||
$data = hook_playvideos_render_header($data);
|
$data = hook_playvideos_render_header($data);
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertEquals(1, count($data['buttons_toolbar']));
|
$this->assertEquals(1, count($data['buttons_toolbar']));
|
||||||
|
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = $str;
|
$data['_PAGE_'] = $str;
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertArrayNotHasKey('buttons_toolbar', $data);
|
$this->assertArrayNotHasKey('buttons_toolbar', $data);
|
||||||
|
@ -49,14 +50,14 @@ class PluginPlayvideosTest extends \Shaarli\TestCase
|
||||||
public function testPlayvideosFooter()
|
public function testPlayvideosFooter()
|
||||||
{
|
{
|
||||||
$str = 'stuff';
|
$str = 'stuff';
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||||
|
|
||||||
$data = hook_playvideos_render_footer($data);
|
$data = hook_playvideos_render_footer($data);
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertEquals(2, count($data['js_files']));
|
$this->assertEquals(2, count($data['js_files']));
|
||||||
|
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = $str;
|
$data['_PAGE_'] = $str;
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertArrayNotHasKey('js_files', $data);
|
$this->assertArrayNotHasKey('js_files', $data);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Pubsubhubbub;
|
namespace Shaarli\Plugin\Pubsubhubbub;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
@ -37,7 +38,7 @@ class PluginPubsubhubbubTest extends \Shaarli\TestCase
|
||||||
$data['_PAGE_'] = TemplatePage::FEED_RSS;
|
$data['_PAGE_'] = TemplatePage::FEED_RSS;
|
||||||
|
|
||||||
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
||||||
$expected = '<atom:link rel="hub" href="'. $hub .'" />';
|
$expected = '<atom:link rel="hub" href="' . $hub . '" />';
|
||||||
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class PluginPubsubhubbubTest extends \Shaarli\TestCase
|
||||||
$data['_PAGE_'] = TemplatePage::FEED_ATOM;
|
$data['_PAGE_'] = TemplatePage::FEED_ATOM;
|
||||||
|
|
||||||
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
$data = hook_pubsubhubbub_render_feed($data, $conf);
|
||||||
$expected = '<link rel="hub" href="'. $hub .'" />';
|
$expected = '<link rel="hub" href="' . $hub . '" />';
|
||||||
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
$this->assertEquals($expected, $data['feed_plugins_header'][0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Qrcode;
|
namespace Shaarli\Plugin\Qrcode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,14 +31,14 @@ class PluginQrcodeTest extends \Shaarli\TestCase
|
||||||
public function testQrcodeLinklist()
|
public function testQrcodeLinklist()
|
||||||
{
|
{
|
||||||
$str = 'http://randomstr.com/test';
|
$str = 'http://randomstr.com/test';
|
||||||
$data = array(
|
$data = [
|
||||||
'title' => $str,
|
'title' => $str,
|
||||||
'links' => array(
|
'links' => [
|
||||||
array(
|
[
|
||||||
'url' => $str,
|
'url' => $str,
|
||||||
)
|
]
|
||||||
)
|
]
|
||||||
);
|
];
|
||||||
|
|
||||||
$data = hook_qrcode_render_linklist($data);
|
$data = hook_qrcode_render_linklist($data);
|
||||||
$link = $data['links'][0];
|
$link = $data['links'][0];
|
||||||
|
@ -56,14 +57,14 @@ class PluginQrcodeTest extends \Shaarli\TestCase
|
||||||
public function testQrcodeFooter()
|
public function testQrcodeFooter()
|
||||||
{
|
{
|
||||||
$str = 'stuff';
|
$str = 'stuff';
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
$data['_PAGE_'] = TemplatePage::LINKLIST;
|
||||||
|
|
||||||
$data = hook_qrcode_render_footer($data);
|
$data = hook_qrcode_render_footer($data);
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertEquals(1, count($data['js_files']));
|
$this->assertEquals(1, count($data['js_files']));
|
||||||
|
|
||||||
$data = array($str => $str);
|
$data = [$str => $str];
|
||||||
$data['_PAGE_'] = $str;
|
$data['_PAGE_'] = $str;
|
||||||
$this->assertEquals($str, $data[$str]);
|
$this->assertEquals($str, $data[$str]);
|
||||||
$this->assertArrayNotHasKey('js_files', $data);
|
$this->assertArrayNotHasKey('js_files', $data);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Wallabag;
|
namespace Shaarli\Plugin\Wallabag;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin\Wallabag;
|
namespace Shaarli\Plugin\Wallabag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@ class PageCacheManagerTest extends TestCase
|
||||||
protected static $testCacheDir = 'sandbox/dummycache';
|
protected static $testCacheDir = 'sandbox/dummycache';
|
||||||
|
|
||||||
// dummy cached file names / content
|
// dummy cached file names / content
|
||||||
protected static $pages = array('a', 'toto', 'd7b59c');
|
protected static $pages = ['a', 'toto', 'd7b59c'];
|
||||||
|
|
||||||
/** @var PageCacheManager */
|
/** @var PageCacheManager */
|
||||||
protected $cacheManager;
|
protected $cacheManager;
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ThemeUtilsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
$themes = ['theme1', 'default', 'Bl1p_- bL0p'];
|
$themes = ['theme1', 'default', 'Bl1p_- bL0p'];
|
||||||
foreach ($themes as $theme) {
|
foreach ($themes as $theme) {
|
||||||
mkdir('sandbox/tpl/'. $theme, 0755, true);
|
mkdir('sandbox/tpl/' . $theme, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// include a file which should be ignored
|
// include a file which should be ignored
|
||||||
|
@ -29,7 +29,7 @@ class ThemeUtilsTest extends \Shaarli\TestCase
|
||||||
$this->assertFalse(in_array('supertheme', $res));
|
$this->assertFalse(in_array('supertheme', $res));
|
||||||
|
|
||||||
foreach ($themes as $theme) {
|
foreach ($themes as $theme) {
|
||||||
rmdir('sandbox/tpl/'. $theme);
|
rmdir('sandbox/tpl/' . $theme);
|
||||||
}
|
}
|
||||||
unlink('sandbox/tpl/supertheme');
|
unlink('sandbox/tpl/supertheme');
|
||||||
rmdir('sandbox/tpl');
|
rmdir('sandbox/tpl');
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Shaarli\Security;
|
namespace Shaarli\Security;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
|
@ -349,7 +349,11 @@ class LoginManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->configManager->set('ldap.host', 'dummy');
|
$this->configManager->set('ldap.host', 'dummy');
|
||||||
$this->assertFalse(
|
$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->configManager->set('ldap.host', 'dummy');
|
||||||
$this->assertTrue(
|
$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
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Updater;
|
namespace Shaarli\Updater;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Updater;
|
namespace Shaarli\Updater;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -10,7 +11,6 @@ use Shaarli\History;
|
||||||
use Shaarli\Plugin\PluginManager;
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\TestCase;
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UpdaterTest.
|
* Class UpdaterTest.
|
||||||
* Runs unit tests against the updater class.
|
* Runs unit tests against the updater class.
|
||||||
|
@ -50,7 +50,7 @@ class UpdaterTest extends TestCase
|
||||||
$this->refDB = new \ReferenceLinkDB();
|
$this->refDB = new \ReferenceLinkDB();
|
||||||
$this->refDB->write(self::$testDatastore);
|
$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->conf = new ConfigManager(self::$configFile);
|
||||||
$this->bookmarkService = new BookmarkFileService(
|
$this->bookmarkService = new BookmarkFileService(
|
||||||
$this->conf,
|
$this->conf,
|
||||||
|
@ -67,10 +67,10 @@ class UpdaterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testReadEmptyUpdatesFile()
|
public function testReadEmptyUpdatesFile()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array(), UpdaterUtils::readUpdatesFile(''));
|
$this->assertEquals([], UpdaterUtils::readUpdatesFile(''));
|
||||||
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
||||||
touch($updatesFile);
|
touch($updatesFile);
|
||||||
$this->assertEquals(array(), UpdaterUtils::readUpdatesFile($updatesFile));
|
$this->assertEquals([], UpdaterUtils::readUpdatesFile($updatesFile));
|
||||||
unlink($updatesFile);
|
unlink($updatesFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class UpdaterTest extends TestCase
|
||||||
public function testReadWriteUpdatesFile()
|
public function testReadWriteUpdatesFile()
|
||||||
{
|
{
|
||||||
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
||||||
$updatesMethods = array('m1', 'm2', 'm3');
|
$updatesMethods = ['m1', 'm2', 'm3'];
|
||||||
|
|
||||||
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
|
UpdaterUtils::writeUpdatesFile($updatesFile, $updatesMethods);
|
||||||
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
|
$readMethods = UpdaterUtils::readUpdatesFile($updatesFile);
|
||||||
|
@ -102,7 +102,7 @@ class UpdaterTest extends TestCase
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
||||||
|
|
||||||
UpdaterUtils::writeUpdatesFile('', array('test'));
|
UpdaterUtils::writeUpdatesFile('', ['test']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ class UpdaterTest extends TestCase
|
||||||
touch($updatesFile);
|
touch($updatesFile);
|
||||||
chmod($updatesFile, 0444);
|
chmod($updatesFile, 0444);
|
||||||
try {
|
try {
|
||||||
@UpdaterUtils::writeUpdatesFile($updatesFile, array('test'));
|
@UpdaterUtils::writeUpdatesFile($updatesFile, ['test']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
unlink($updatesFile);
|
unlink($updatesFile);
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -131,17 +131,17 @@ class UpdaterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testNoUpdates()
|
public function testNoUpdates()
|
||||||
{
|
{
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
'updateMethodException',
|
'updateMethodException',
|
||||||
);
|
];
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$this->assertEquals(array(), $updater->update());
|
$this->assertEquals([], $updater->update());
|
||||||
|
|
||||||
$updater = new DummyUpdater(array(), array(), $this->conf, false);
|
$updater = new DummyUpdater([], [], $this->conf, false);
|
||||||
$this->assertEquals(array(), $updater->update());
|
$this->assertEquals([], $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,13 +149,13 @@ class UpdaterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testUpdatesFirstTime()
|
public function testUpdatesFirstTime()
|
||||||
{
|
{
|
||||||
$updates = array('updateMethodException',);
|
$updates = ['updateMethodException',];
|
||||||
$expectedUpdates = array(
|
$expectedUpdates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
);
|
];
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$this->assertEquals($expectedUpdates, $updater->update());
|
$this->assertEquals($expectedUpdates, $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,14 +164,14 @@ class UpdaterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testOneUpdate()
|
public function testOneUpdate()
|
||||||
{
|
{
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
'updateMethodException',
|
'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());
|
$this->assertEquals($expectedUpdate, $updater->update());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,13 +182,13 @@ class UpdaterTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
|
|
||||||
$updates = array(
|
$updates = [
|
||||||
'updateMethodDummy1',
|
'updateMethodDummy1',
|
||||||
'updateMethodDummy2',
|
'updateMethodDummy2',
|
||||||
'updateMethodDummy3',
|
'updateMethodDummy3',
|
||||||
);
|
];
|
||||||
|
|
||||||
$updater = new DummyUpdater($updates, array(), $this->conf, true);
|
$updater = new DummyUpdater($updates, [], $this->conf, true);
|
||||||
$updater->update();
|
$updater->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Old-style mock for cURL, as PHPUnit doesn't allow to mock global functions
|
* Old-style mock for cURL, as PHPUnit doesn't allow to mock global functions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Shaarli\Bookmark\BookmarkArray;
|
use Shaarli\Bookmark\BookmarkArray;
|
||||||
use Shaarli\Bookmark\BookmarkFilter;
|
use Shaarli\Bookmark\BookmarkFilter;
|
||||||
use Shaarli\Bookmark\BookmarkIO;
|
use Shaarli\Bookmark\BookmarkIO;
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ReferenceLinkDB
|
||||||
{
|
{
|
||||||
public static $NB_LINKS_TOTAL = 11;
|
public static $NB_LINKS_TOTAL = 11;
|
||||||
|
|
||||||
private $bookmarks = array();
|
private $bookmarks = [];
|
||||||
private $_publicCount = 0;
|
private $_publicCount = 0;
|
||||||
private $_privateCount = 0;
|
private $_privateCount = 0;
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ class ReferenceLinkDB
|
||||||
$shorturl = '',
|
$shorturl = '',
|
||||||
$pinned = false
|
$pinned = false
|
||||||
) {
|
) {
|
||||||
$link = array(
|
$link = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
|
@ -175,7 +175,7 @@ class ReferenceLinkDB
|
||||||
'updated' => $updated,
|
'updated' => $updated,
|
||||||
'shorturl' => $shorturl ? $shorturl : smallHash($date->format(Bookmark::LINK_DATE_FORMAT) . $id),
|
'shorturl' => $shorturl ? $shorturl : smallHash($date->format(Bookmark::LINK_DATE_FORMAT) . $id),
|
||||||
'sticky' => $pinned
|
'sticky' => $pinned
|
||||||
);
|
];
|
||||||
if (! $this->isLegacy) {
|
if (! $this->isLegacy) {
|
||||||
$bookmark = new Bookmark();
|
$bookmark = new Bookmark();
|
||||||
$this->bookmarks[$id] = $bookmark->fromArray($link);
|
$this->bookmarks[$id] = $bookmark->fromArray($link);
|
||||||
|
@ -198,7 +198,7 @@ class ReferenceLinkDB
|
||||||
$this->reorder();
|
$this->reorder();
|
||||||
file_put_contents(
|
file_put_contents(
|
||||||
$filename,
|
$filename,
|
||||||
'<?php /* '.base64_encode(gzdeflate(serialize($this->bookmarks))).' */ ?>'
|
'<?php /* ' . base64_encode(gzdeflate(serialize($this->bookmarks))) . ' */ ?>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Testing the untestable - Session ID generation
|
* Testing the untestable - Session ID generation
|
||||||
*/
|
*/
|
||||||
|
@ -13,9 +14,9 @@ class ReferenceSessionIdHashes
|
||||||
public static function genAllHashes()
|
public static function genAllHashes()
|
||||||
{
|
{
|
||||||
foreach (hash_algos() as $algo) {
|
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);
|
self::$sidHashes[$algo][$bpc] = self::genSidHash($algo, $bpc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$GLOBALS['login'] = 'root';
|
$GLOBALS['login'] = 'root';
|
||||||
$GLOBALS['hash'] = 'hash';
|
$GLOBALS['hash'] = 'hash';
|
||||||
$GLOBALS['salt'] = 'salt';
|
$GLOBALS['salt'] = 'salt';
|
||||||
|
|
Loading…
Reference in a new issue