Merge pull request #1575 from ArthurHoaro/feature/php8
This commit is contained in:
commit
7b18876361
115 changed files with 690 additions and 785 deletions
|
@ -3,6 +3,14 @@ dist: bionic
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# jobs for each supported php version
|
# jobs for each supported php version
|
||||||
|
- language: php
|
||||||
|
php: nightly # PHP 8.0
|
||||||
|
install:
|
||||||
|
- composer self-update --2
|
||||||
|
- composer update --ignore-platform-req=php
|
||||||
|
- composer remove --dev --ignore-platform-req=php phpunit/phpunit
|
||||||
|
- composer require --dev --ignore-platform-req=php phpunit/php-text-template ^2.0
|
||||||
|
- composer require --dev --ignore-platform-req=php phpunit/phpunit ^9.0
|
||||||
- language: php
|
- language: php
|
||||||
php: 7.4
|
php: 7.4
|
||||||
- language: php
|
- language: php
|
||||||
|
|
|
@ -46,7 +46,7 @@ public function write($filepath, $conf)
|
||||||
// JSON_PRETTY_PRINT is available from PHP 5.4.
|
// JSON_PRETTY_PRINT is available from PHP 5.4.
|
||||||
$print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
|
$print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
|
||||||
$data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
|
$data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
|
||||||
if (!file_put_contents($filepath, $data)) {
|
if (empty($filepath) || !file_put_contents($filepath, $data)) {
|
||||||
throw new \Shaarli\Exceptions\IOException(
|
throw new \Shaarli\Exceptions\IOException(
|
||||||
$filepath,
|
$filepath,
|
||||||
t('Shaarli could not create the config file. '.
|
t('Shaarli could not create the config file. '.
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"roave/security-advisories": "dev-master",
|
"roave/security-advisories": "dev-master",
|
||||||
"phpunit/phpcov": "*",
|
"squizlabs/php_codesniffer": "3.*",
|
||||||
"phpunit/phpunit": "^7.5 || ^8.0",
|
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
|
||||||
"squizlabs/php_codesniffer": "3.*"
|
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
||||||
|
|
805
composer.lock
generated
805
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for Shaarli utilities
|
* Unitary tests for Shaarli utilities
|
||||||
*/
|
*/
|
||||||
class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase
|
class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
protected static $testUpdateFile = 'sandbox/update.txt';
|
protected static $testUpdateFile = 'sandbox/update.txt';
|
||||||
protected static $testVersion = '0.5.0';
|
protected static $testVersion = '0.5.0';
|
||||||
|
@ -144,10 +144,10 @@ public function testCheckUpdateNewVersionUnavailable()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test update checks - invalid Git branch
|
* Test update checks - invalid Git branch
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testCheckUpdateInvalidGitBranch()
|
public function testCheckUpdateInvalidGitBranch()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid branch selected for updates/');
|
$this->expectExceptionMessageRegExp('/Invalid branch selected for updates/');
|
||||||
|
|
||||||
ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable');
|
ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable');
|
||||||
|
@ -261,10 +261,10 @@ public function testCheckSupportedPHPVersion()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a unsupported PHP version
|
* Check a unsupported PHP version
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testCheckSupportedPHPVersion51()
|
public function testCheckSupportedPHPVersion51()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
|
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
|
||||||
|
|
||||||
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0'));
|
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0'));
|
||||||
|
@ -272,10 +272,10 @@ public function testCheckSupportedPHPVersion51()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check another unsupported PHP version
|
* Check another unsupported PHP version
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testCheckSupportedPHPVersion52()
|
public function testCheckSupportedPHPVersion52()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
|
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
|
||||||
|
|
||||||
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2'));
|
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2'));
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Test file utility class.
|
* Test file utility class.
|
||||||
*/
|
*/
|
||||||
class FileUtilsTest extends \PHPUnit\Framework\TestCase
|
class FileUtilsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Test file path.
|
* @var string Test file path.
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
namespace Shaarli;
|
namespace Shaarli;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Exception;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
|
|
||||||
class HistoryTest extends \PHPUnit\Framework\TestCase
|
class HistoryTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string History file path
|
* @var string History file path
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
/**
|
/**
|
||||||
* Class LanguagesTest.
|
* Class LanguagesTest.
|
||||||
*/
|
*/
|
||||||
class LanguagesTest extends \PHPUnit\Framework\TestCase
|
class LanguagesTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Config file path (without extension).
|
* @var string Config file path (without extension).
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Shaarli\Plugin;
|
namespace Shaarli\Plugin;
|
||||||
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
@ -6,7 +7,7 @@
|
||||||
/**
|
/**
|
||||||
* Unit tests for Plugins
|
* Unit tests for Plugins
|
||||||
*/
|
*/
|
||||||
class PluginManagerTest extends \PHPUnit\Framework\TestCase
|
class PluginManagerTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Path to tests plugin.
|
* Path to tests plugin.
|
||||||
|
@ -81,8 +82,8 @@ public function testPluginWithPhpError(): void
|
||||||
$data = [];
|
$data = [];
|
||||||
$this->pluginManager->executeHooks('error', $data);
|
$this->pluginManager->executeHooks('error', $data);
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertRegExp(
|
||||||
'test [plugin incompatibility]: Class \'Unknown\' not found',
|
'/test \[plugin incompatibility\]: Class [\'"]Unknown[\'"] not found/',
|
||||||
$this->pluginManager->getErrors()[0]
|
$this->pluginManager->getErrors()[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
77
tests/TestCase.php
Normal file
77
tests/TestCase.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shaarli;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class extending \PHPUnit\Framework\TestCase.
|
||||||
|
* Used to make Shaarli UT run on multiple versions of PHPUnit.
|
||||||
|
*/
|
||||||
|
class TestCase extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* expectExceptionMessageRegExp has been removed and replaced by expectExceptionMessageMatches in PHPUnit 9.
|
||||||
|
*/
|
||||||
|
public function expectExceptionMessageRegExp(string $regularExpression): void
|
||||||
|
{
|
||||||
|
if (method_exists($this, 'expectExceptionMessageMatches')) {
|
||||||
|
$this->expectExceptionMessageMatches($regularExpression);
|
||||||
|
} else {
|
||||||
|
parent::expectExceptionMessageRegExp($regularExpression);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assertContains is now used for iterable, strings should use assertStringContainsString
|
||||||
|
*/
|
||||||
|
public function assertContainsPolyfill($expected, $actual, string $message = ''): void
|
||||||
|
{
|
||||||
|
if (is_string($actual) && method_exists($this, 'assertStringContainsString')) {
|
||||||
|
static::assertStringContainsString($expected, $actual, $message);
|
||||||
|
} else {
|
||||||
|
static::assertContains($expected, $actual, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assertNotContains is now used for iterable, strings should use assertStringNotContainsString
|
||||||
|
*/
|
||||||
|
public function assertNotContainsPolyfill($expected, $actual, string $message = ''): void
|
||||||
|
{
|
||||||
|
if (is_string($actual) && method_exists($this, 'assertStringNotContainsString')) {
|
||||||
|
static::assertStringNotContainsString($expected, $actual, $message);
|
||||||
|
} else {
|
||||||
|
static::assertNotContains($expected, $actual, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assertFileNotExists has been renamed in assertFileDoesNotExist
|
||||||
|
*/
|
||||||
|
public static function assertFileNotExists(string $filename, string $message = ''): void
|
||||||
|
{
|
||||||
|
if (method_exists(TestCase::class, 'assertFileDoesNotExist')) {
|
||||||
|
static::assertFileDoesNotExist($filename, $message);
|
||||||
|
} else {
|
||||||
|
parent::assertFileNotExists($filename, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* assertRegExp has been renamed in assertMatchesRegularExpression
|
||||||
|
*/
|
||||||
|
public static function assertRegExp(string $pattern, string $string, string $message = ''): void
|
||||||
|
{
|
||||||
|
if (method_exists(TestCase::class, 'assertMatchesRegularExpression')) {
|
||||||
|
static::assertMatchesRegularExpression($pattern, $string, $message);
|
||||||
|
} else {
|
||||||
|
parent::assertRegExp($pattern, $string, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isInTestsContext(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Shaarli;
|
namespace Shaarli;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use WebThumbnailer\Application\ConfigManager as WTConfigManager;
|
use WebThumbnailer\Application\ConfigManager as WTConfigManager;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for timezone utilities
|
* Unitary tests for timezone utilities
|
||||||
*/
|
*/
|
||||||
class TimeZoneTest extends PHPUnit\Framework\TestCase
|
class TimeZoneTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array of timezones
|
* @var array of timezones
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for Shaarli utilities
|
* Unitary tests for Shaarli utilities
|
||||||
*/
|
*/
|
||||||
class UtilsTest extends PHPUnit\Framework\TestCase
|
class UtilsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
// Log file
|
// Log file
|
||||||
protected static $testLogFile = 'tests.log';
|
protected static $testLogFile = 'tests.log';
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* @package Api
|
* @package Api
|
||||||
*/
|
*/
|
||||||
class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
@ -26,7 +26,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
||||||
protected static $testDatastore = 'sandbox/datastore.php';
|
protected static $testDatastore = 'sandbox/datastore.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \ConfigManager instance
|
* @var ConfigManager instance
|
||||||
*/
|
*/
|
||||||
protected $conf;
|
protected $conf;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public function testInvokeMiddlewareApiDisabledDebug()
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$this->assertEquals(401, $response->getStatusCode());
|
||||||
$body = json_decode((string) $response->getBody());
|
$body = json_decode((string) $response->getBody());
|
||||||
$this->assertEquals('Not authorized: API is disabled', $body->message);
|
$this->assertEquals('Not authorized: API is disabled', $body->message);
|
||||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +179,7 @@ public function testInvokeMiddlewareNoTokenProvidedDebug()
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$this->assertEquals(401, $response->getStatusCode());
|
||||||
$body = json_decode((string) $response->getBody());
|
$body = json_decode((string) $response->getBody());
|
||||||
$this->assertEquals('Not authorized: JWT token not provided', $body->message);
|
$this->assertEquals('Not authorized: JWT token not provided', $body->message);
|
||||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +204,7 @@ public function testInvokeMiddlewareNoSecretSetDebug()
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$this->assertEquals(401, $response->getStatusCode());
|
||||||
$body = json_decode((string) $response->getBody());
|
$body = json_decode((string) $response->getBody());
|
||||||
$this->assertEquals('Not authorized: Token secret must be set in Shaarli\'s administration', $body->message);
|
$this->assertEquals('Not authorized: Token secret must be set in Shaarli\'s administration', $body->message);
|
||||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,7 +227,7 @@ public function testInvalidJwtAuthHeaderDebug()
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$this->assertEquals(401, $response->getStatusCode());
|
||||||
$body = json_decode((string) $response->getBody());
|
$body = json_decode((string) $response->getBody());
|
||||||
$this->assertEquals('Not authorized: Invalid JWT header', $body->message);
|
$this->assertEquals('Not authorized: Invalid JWT header', $body->message);
|
||||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -253,6 +253,6 @@ public function testInvokeMiddlewareInvalidJwtDebug()
|
||||||
$this->assertEquals(401, $response->getStatusCode());
|
$this->assertEquals(401, $response->getStatusCode());
|
||||||
$body = json_decode((string) $response->getBody());
|
$body = json_decode((string) $response->getBody());
|
||||||
$this->assertEquals('Not authorized: Malformed JWT token', $body->message);
|
$this->assertEquals('Not authorized: Malformed JWT token', $body->message);
|
||||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/**
|
/**
|
||||||
* Class ApiUtilsTest
|
* Class ApiUtilsTest
|
||||||
*/
|
*/
|
||||||
class ApiUtilsTest extends \PHPUnit\Framework\TestCase
|
class ApiUtilsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Force the timezone for ISO datetimes.
|
* Force the timezone for ISO datetimes.
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
require_once 'tests/utils/ReferenceHistory.php';
|
require_once 'tests/utils/ReferenceHistory.php';
|
||||||
|
|
||||||
class HistoryTest extends \PHPUnit\Framework\TestCase
|
class HistoryTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\BookmarkFileService;
|
use Shaarli\Bookmark\BookmarkFileService;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Container;
|
use Slim\Container;
|
||||||
use Slim\Http\Environment;
|
use Slim\Http\Environment;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
class DeleteLinkTest extends \PHPUnit\Framework\TestCase
|
class DeleteLinkTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* @package Shaarli\Api\Controllers
|
* @package Shaarli\Api\Controllers
|
||||||
*/
|
*/
|
||||||
class GetLinkIdTest extends \PHPUnit\Framework\TestCase
|
class GetLinkIdTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* @package Shaarli\Api\Controllers
|
* @package Shaarli\Api\Controllers
|
||||||
*/
|
*/
|
||||||
class GetLinksTest extends \PHPUnit\Framework\TestCase
|
class GetLinksTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace Shaarli\Api\Controllers;
|
namespace Shaarli\Api\Controllers;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\BookmarkFileService;
|
use Shaarli\Bookmark\BookmarkFileService;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Container;
|
use Slim\Container;
|
||||||
use Slim\Http\Environment;
|
use Slim\Http\Environment;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
class PutLinkTest extends \PHPUnit\Framework\TestCase
|
class PutLinkTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
class DeleteTagTest extends \PHPUnit\Framework\TestCase
|
class DeleteTagTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* @package Shaarli\Api\Controllers
|
* @package Shaarli\Api\Controllers
|
||||||
*/
|
*/
|
||||||
class GetTagNameTest extends \PHPUnit\Framework\TestCase
|
class GetTagNameTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*
|
*
|
||||||
* @package Shaarli\Api\Controllers
|
* @package Shaarli\Api\Controllers
|
||||||
*/
|
*/
|
||||||
class GetTagsTest extends \PHPUnit\Framework\TestCase
|
class GetTagsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
class PutTagTest extends \PHPUnit\Framework\TestCase
|
class PutTagTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string datastore to test write operations
|
* @var string datastore to test write operations
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Bookmark\Exception\InvalidBookmarkException;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
|
||||||
use Shaarli\History;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkArrayTest
|
* Class BookmarkArrayTest
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use ReferenceLinkDB;
|
use ReferenceLinkDB;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use Shaarli;
|
use Shaarli;
|
||||||
|
@ -14,6 +13,7 @@
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Formatter\BookmarkMarkdownFormatter;
|
use Shaarli\Formatter\BookmarkMarkdownFormatter;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unitary tests for LegacyLinkDBTest
|
* Unitary tests for LegacyLinkDBTest
|
||||||
|
@ -637,11 +637,10 @@ public function testInitialize()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Attempt to instantiate a LinkDB whereas the datastore is not writable
|
* Attempt to instantiate a LinkDB whereas the datastore is not writable
|
||||||
*
|
|
||||||
* @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException
|
|
||||||
*/
|
*/
|
||||||
public function testConstructDatastoreNotWriteable()
|
public function testConstructDatastoreNotWriteable()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Shaarli\Bookmark\Exception\NotWritableDataStoreException::class);
|
||||||
$this->expectExceptionMessageRegExp('#Couldn\'t load data from the data store file "null".*#');
|
$this->expectExceptionMessageRegExp('#Couldn\'t load data from the data store file "null".*#');
|
||||||
|
|
||||||
$conf = new ConfigManager('tests/utils/config/configJson');
|
$conf = new ConfigManager('tests/utils/config/configJson');
|
||||||
|
@ -748,7 +747,7 @@ public function testGetKnownLinkFromURL()
|
||||||
$link = $this->publicLinkDB->findByUrl('http://mediagoblin.org/');
|
$link = $this->publicLinkDB->findByUrl('http://mediagoblin.org/');
|
||||||
|
|
||||||
$this->assertNotEquals(false, $link);
|
$this->assertNotEquals(false, $link);
|
||||||
$this->assertContains(
|
$this->assertContainsPolyfill(
|
||||||
'A free software media publishing platform',
|
'A free software media publishing platform',
|
||||||
$link->getDescription()
|
$link->getDescription()
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use ReferenceLinkDB;
|
use ReferenceLinkDB;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkFilterTest.
|
* Class BookmarkFilterTest.
|
||||||
|
@ -212,10 +212,10 @@ public function testFilterUnknownDay()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use an invalid date format
|
* Use an invalid date format
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testFilterInvalidDayWithChars()
|
public function testFilterInvalidDayWithChars()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
||||||
|
|
||||||
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away');
|
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away');
|
||||||
|
@ -223,10 +223,10 @@ public function testFilterInvalidDayWithChars()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use an invalid date format
|
* Use an invalid date format
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testFilterInvalidDayDigits()
|
public function testFilterInvalidDayDigits()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
||||||
|
|
||||||
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20');
|
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20');
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkInitializerTest
|
* Class BookmarkInitializerTest
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Exception\InvalidBookmarkException;
|
use Shaarli\Bookmark\Exception\InvalidBookmarkException;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkTest
|
* Class BookmarkTest
|
||||||
|
@ -150,7 +150,7 @@ public function testValidateNotValidNoId()
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContains('- ID: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- ID: '. PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +169,7 @@ public function testValidateNotValidStringId()
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContains('- ID: str'. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- ID: str'. PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,7 +188,7 @@ public function testValidateNotValidNoShortUrl()
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContains('- ShortUrl: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- ShortUrl: '. PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +207,7 @@ public function testValidateNotValidNoCreated()
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContains('- Created: '. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- Created: '. PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +226,7 @@ public function testValidateNotValidBadCreated()
|
||||||
$exception = $e;
|
$exception = $e;
|
||||||
}
|
}
|
||||||
$this->assertNotNull($exception);
|
$this->assertNotNull($exception);
|
||||||
$this->assertContains('- Created: Not a DateTime object'. PHP_EOL, $exception->getMessage());
|
$this->assertContainsPolyfill('- Created: Not a DateTime object'. PHP_EOL, $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Bookmark;
|
namespace Shaarli\Bookmark;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
require_once 'tests/utils/CurlUtils.php';
|
require_once 'tests/utils/CurlUtils.php';
|
||||||
|
|
||||||
|
@ -450,13 +450,13 @@ public function testHashtagAutolink()
|
||||||
カタカナ #カタカナ」カタカナ\n';
|
カタカナ #カタカナ」カタカナ\n';
|
||||||
$autolinkedDescription = hashtag_autolink($rawDescription, $index);
|
$autolinkedDescription = hashtag_autolink($rawDescription, $index);
|
||||||
|
|
||||||
$this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription);
|
$this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription);
|
||||||
$this->assertNotContains(' #hashtag', $autolinkedDescription);
|
$this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
|
||||||
$this->assertNotContains('>#nothashtag', $autolinkedDescription);
|
$this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
|
||||||
$this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription);
|
$this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription);
|
||||||
$this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription);
|
$this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription);
|
||||||
$this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription);
|
$this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription);
|
||||||
$this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription);
|
$this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,9 +467,9 @@ public function testHashtagAutolinkNoIndex()
|
||||||
$rawDescription = 'blabla #hashtag x#nothashtag';
|
$rawDescription = 'blabla #hashtag x#nothashtag';
|
||||||
$autolinkedDescription = hashtag_autolink($rawDescription);
|
$autolinkedDescription = hashtag_autolink($rawDescription);
|
||||||
|
|
||||||
$this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription);
|
$this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription);
|
||||||
$this->assertNotContains(' #hashtag', $autolinkedDescription);
|
$this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
|
||||||
$this->assertNotContains('>#nothashtag', $autolinkedDescription);
|
$this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@ function is_iterable($var)
|
||||||
require_once 'application/Utils.php';
|
require_once 'application/Utils.php';
|
||||||
require_once 'application/http/UrlUtils.php';
|
require_once 'application/http/UrlUtils.php';
|
||||||
require_once 'application/http/HttpUtils.php';
|
require_once 'application/http/HttpUtils.php';
|
||||||
|
require_once 'tests/TestCase.php';
|
||||||
require_once 'tests/container/ShaarliTestContainer.php';
|
require_once 'tests/container/ShaarliTestContainer.php';
|
||||||
require_once 'tests/front/controller/visitor/FrontControllerMockHelper.php';
|
require_once 'tests/front/controller/visitor/FrontControllerMockHelper.php';
|
||||||
require_once 'tests/front/controller/admin/FrontAdminControllerMockHelper.php';
|
require_once 'tests/front/controller/admin/FrontAdminControllerMockHelper.php';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/**
|
/**
|
||||||
* Class ConfigJsonTest
|
* Class ConfigJsonTest
|
||||||
*/
|
*/
|
||||||
class ConfigJsonTest extends \PHPUnit\Framework\TestCase
|
class ConfigJsonTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ConfigJson
|
* @var ConfigJson
|
||||||
|
@ -42,7 +42,7 @@ public function testReadNonExistent()
|
||||||
public function testReadInvalidJson()
|
public function testReadInvalidJson()
|
||||||
{
|
{
|
||||||
$this->expectException(\Exception::class);
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp(' /An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
|
$this->expectExceptionMessageRegExp('/An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
|
||||||
|
|
||||||
$this->configIO->read('tests/utils/config/configInvalid.json.php');
|
$this->configIO->read('tests/utils/config/configInvalid.json.php');
|
||||||
}
|
}
|
||||||
|
@ -108,17 +108,6 @@ public function testOverwrite()
|
||||||
unlink($dest);
|
unlink($dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write to invalid path.
|
|
||||||
*/
|
|
||||||
public function testWriteInvalidArray()
|
|
||||||
{
|
|
||||||
$this->expectException(\Shaarli\Exceptions\IOException::class);
|
|
||||||
|
|
||||||
$conf = array('conf' => 'value');
|
|
||||||
@$this->configIO->write(array(), $conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to invalid path.
|
* Write to invalid path.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Note: it only test the manager with ConfigJson,
|
* Note: it only test the manager with ConfigJson,
|
||||||
* ConfigPhp is only a workaround to handle the transition to JSON type.
|
* ConfigPhp is only a workaround to handle the transition to JSON type.
|
||||||
*/
|
*/
|
||||||
class ConfigManagerTest extends \PHPUnit\Framework\TestCase
|
class ConfigManagerTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ConfigManager
|
* @var ConfigManager
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* which are kept between tests.
|
* which are kept between tests.
|
||||||
* @runTestsInSeparateProcesses
|
* @runTestsInSeparateProcesses
|
||||||
*/
|
*/
|
||||||
class ConfigPhpTest extends \PHPUnit\Framework\TestCase
|
class ConfigPhpTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ConfigPhp
|
* @var ConfigPhp
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for Shaarli config related functions
|
* Unitary tests for Shaarli config related functions
|
||||||
*/
|
*/
|
||||||
class ConfigPluginTest extends \PHPUnit\Framework\TestCase
|
class ConfigPluginTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test save_plugin_config with valid data.
|
* Test save_plugin_config with valid data.
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Container;
|
namespace Shaarli\Container;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\BookmarkServiceInterface;
|
use Shaarli\Bookmark\BookmarkServiceInterface;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Feed\FeedBuilder;
|
use Shaarli\Feed\FeedBuilder;
|
||||||
|
@ -20,6 +19,7 @@
|
||||||
use Shaarli\Security\CookieManager;
|
use Shaarli\Security\CookieManager;
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Shaarli\Updater\Updater;
|
use Shaarli\Updater\Updater;
|
||||||
use Slim\Http\Environment;
|
use Slim\Http\Environment;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for cached pages
|
* Unitary tests for cached pages
|
||||||
*/
|
*/
|
||||||
class CachedPageTest extends \PHPUnit\Framework\TestCase
|
class CachedPageTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
// test cache directory
|
// test cache directory
|
||||||
protected static $testCacheDir = 'sandbox/pagecache';
|
protected static $testCacheDir = 'sandbox/pagecache';
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Shaarli\Feed;
|
namespace Shaarli\Feed;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use ReferenceLinkDB;
|
use ReferenceLinkDB;
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\BookmarkFileService;
|
use Shaarli\Bookmark\BookmarkFileService;
|
||||||
|
@ -11,6 +10,7 @@
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Formatter\FormatterFactory;
|
use Shaarli\Formatter\FormatterFactory;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FeedBuilderTest class.
|
* FeedBuilderTest class.
|
||||||
|
@ -97,9 +97,9 @@ public function testRSSBuildData()
|
||||||
$pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']);
|
$pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']);
|
||||||
$up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']);
|
$up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']);
|
||||||
$this->assertEquals($pub, $up);
|
$this->assertEquals($pub, $up);
|
||||||
$this->assertContains('Stallman has a beard', $link['description']);
|
$this->assertContainsPolyfill('Stallman has a beard', $link['description']);
|
||||||
$this->assertContains('Permalink', $link['description']);
|
$this->assertContainsPolyfill('Permalink', $link['description']);
|
||||||
$this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
|
$this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']);
|
||||||
$this->assertEquals(1, count($link['taglist']));
|
$this->assertEquals(1, count($link['taglist']));
|
||||||
$this->assertEquals('sTuff', $link['taglist'][0]);
|
$this->assertEquals('sTuff', $link['taglist'][0]);
|
||||||
|
|
||||||
|
@ -201,16 +201,16 @@ public function testBuildDataPermalinks()
|
||||||
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
|
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
|
||||||
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
|
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
|
||||||
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
|
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
|
||||||
$this->assertContains('Direct link', $link['description']);
|
$this->assertContainsPolyfill('Direct link', $link['description']);
|
||||||
$this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
|
$this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']);
|
||||||
// Second link is a direct link
|
// Second link is a direct link
|
||||||
$link = $data['links'][array_keys($data['links'])[1]];
|
$link = $data['links'][array_keys($data['links'])[1]];
|
||||||
$this->assertEquals(8, $link['id']);
|
$this->assertEquals(8, $link['id']);
|
||||||
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']);
|
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']);
|
||||||
$this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']);
|
$this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']);
|
||||||
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']);
|
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']);
|
||||||
$this->assertContains('Direct link', $link['description']);
|
$this->assertContainsPolyfill('Direct link', $link['description']);
|
||||||
$this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']);
|
$this->assertContainsPolyfill('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,6 +274,6 @@ public function testBuildDataServerSubdir()
|
||||||
$link = $data['links'][array_keys($data['links'])[0]];
|
$link = $data['links'][array_keys($data['links'])[0]];
|
||||||
$this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']);
|
$this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['guid']);
|
||||||
$this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']);
|
$this->assertEquals('http://host.tld:8080/~user/shaarli/shaare/WDWyig', $link['url']);
|
||||||
$this->assertContains('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']);
|
$this->assertContainsPolyfill('http://host.tld:8080/~user/shaarli/./add-tag/hashtag', $link['description']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace Shaarli\Formatter;
|
namespace Shaarli\Formatter;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkDefaultFormatterTest
|
* Class BookmarkDefaultFormatterTest
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace Shaarli\Formatter;
|
namespace Shaarli\Formatter;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkMarkdownFormatterTest
|
* Class BookmarkMarkdownFormatterTest
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
namespace Shaarli\Formatter;
|
namespace Shaarli\Formatter;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BookmarkRawFormatterTest
|
* Class BookmarkRawFormatterTest
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Formatter;
|
namespace Shaarli\Formatter;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FormatterFactoryTest
|
* Class FormatterFactoryTest
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front;
|
namespace Shaarli\Front;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Container\ShaarliContainer;
|
use Shaarli\Container\ShaarliContainer;
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Updater\Updater;
|
use Shaarli\Updater\Updater;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Front;
|
namespace Shaarli\Front;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Container\ShaarliContainer;
|
use Shaarli\Container\ShaarliContainer;
|
||||||
use Shaarli\Front\Exception\LoginBannedException;
|
use Shaarli\Front\Exception\LoginBannedException;
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
use Shaarli\Render\PageBuilder;
|
use Shaarli\Render\PageBuilder;
|
||||||
use Shaarli\Render\PageCacheManager;
|
use Shaarli\Render\PageCacheManager;
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Updater\Updater;
|
use Shaarli\Updater\Updater;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Formatter\BookmarkFormatter;
|
use Shaarli\Formatter\BookmarkFormatter;
|
||||||
use Shaarli\Formatter\BookmarkRawFormatter;
|
use Shaarli\Formatter\BookmarkRawFormatter;
|
||||||
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
use Slim\Http\UploadedFile;
|
use Slim\Http\UploadedFile;
|
||||||
|
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Security\CookieManager;
|
use Shaarli\Security\CookieManager;
|
||||||
use Shaarli\Security\LoginManager;
|
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
use Shaarli\Formatter\BookmarkFormatter;
|
use Shaarli\Formatter\BookmarkFormatter;
|
||||||
|
@ -14,6 +13,7 @@
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
use Shaarli\Formatter\BookmarkFormatter;
|
use Shaarli\Formatter\BookmarkFormatter;
|
||||||
|
@ -13,6 +12,7 @@
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
@ -96,12 +96,14 @@ function (&$charset, &$title, &$description, &$tags) use (
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_editlink'], ['render_includes'])
|
||||||
->willReturnCallback(function (string $hook, array $data) use ($remoteTitle, $remoteDesc): array {
|
->willReturnCallback(function (string $hook, array $data) use ($remoteTitle, $remoteDesc): array {
|
||||||
static::assertSame('render_editlink', $hook);
|
if ('render_editlink' === $hook) {
|
||||||
static::assertSame($remoteTitle, $data['link']['title']);
|
static::assertSame($remoteTitle, $data['link']['title']);
|
||||||
static::assertSame($remoteDesc, $data['link']['description']);
|
static::assertSame($remoteDesc, $data['link']['description']);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||||
|
@ -12,6 +11,7 @@
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Http\HttpAccess;
|
use Shaarli\Http\HttpAccess;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
@ -88,17 +88,18 @@ public function testSaveBookmark(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['save_link'])
|
||||||
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
||||||
static::assertSame('save_link', $hook);
|
if ('save_link' === $hook) {
|
||||||
|
static::assertSame($id, $data['id']);
|
||||||
static::assertSame($id, $data['id']);
|
static::assertSame($parameters['lf_url'], $data['url']);
|
||||||
static::assertSame($parameters['lf_url'], $data['url']);
|
static::assertSame($parameters['lf_title'], $data['title']);
|
||||||
static::assertSame($parameters['lf_title'], $data['title']);
|
static::assertSame($parameters['lf_description'], $data['description']);
|
||||||
static::assertSame($parameters['lf_description'], $data['description']);
|
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
static::assertTrue($data['private']);
|
||||||
static::assertTrue($data['private']);
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
@ -174,17 +175,18 @@ public function testSaveExistingBookmark(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['save_link'])
|
||||||
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
||||||
static::assertSame('save_link', $hook);
|
if ('save_link' === $hook) {
|
||||||
|
static::assertSame($id, $data['id']);
|
||||||
static::assertSame($id, $data['id']);
|
static::assertSame($parameters['lf_url'], $data['url']);
|
||||||
static::assertSame($parameters['lf_url'], $data['url']);
|
static::assertSame($parameters['lf_title'], $data['title']);
|
||||||
static::assertSame($parameters['lf_title'], $data['title']);
|
static::assertSame($parameters['lf_description'], $data['description']);
|
||||||
static::assertSame($parameters['lf_description'], $data['description']);
|
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
static::assertTrue($data['private']);
|
||||||
static::assertTrue($data['private']);
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\BookmarkFilter;
|
use Shaarli\Bookmark\BookmarkFilter;
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\OpenShaarliPasswordException;
|
use Shaarli\Front\Exception\OpenShaarliPasswordException;
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Plugin\PluginManager;
|
use Shaarli\Plugin\PluginManager;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Admin;
|
namespace Shaarli\Front\Controller\Admin;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Security\LoginManager;
|
use Shaarli\Security\LoginManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Feed\CachedPage;
|
use Shaarli\Feed\CachedPage;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
@ -78,19 +78,20 @@ public function testValidIndexControllerInvokeDefault(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_daily'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
|
->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
|
||||||
static::assertSame('render_daily', $hook);
|
if ('render_daily' === $hook) {
|
||||||
|
static::assertArrayHasKey('linksToDisplay', $data);
|
||||||
|
static::assertCount(3, $data['linksToDisplay']);
|
||||||
|
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
||||||
|
static::assertSame($currentDay->getTimestamp(), $data['day']);
|
||||||
|
static::assertSame('20200510', $data['previousday']);
|
||||||
|
static::assertSame('20200516', $data['nextday']);
|
||||||
|
|
||||||
static::assertArrayHasKey('linksToDisplay', $data);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
static::assertCount(3, $data['linksToDisplay']);
|
}
|
||||||
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
|
||||||
static::assertSame($currentDay->getTimestamp(), $data['day']);
|
|
||||||
static::assertSame('20200510', $data['previousday']);
|
|
||||||
static::assertSame('20200516', $data['nextday']);
|
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
@ -203,19 +204,20 @@ public function testValidIndexControllerInvokeNoFutureOrPast(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_daily'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
|
->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
|
||||||
static::assertSame('render_daily', $hook);
|
if ('render_daily' === $hook) {
|
||||||
|
static::assertArrayHasKey('linksToDisplay', $data);
|
||||||
|
static::assertCount(1, $data['linksToDisplay']);
|
||||||
|
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
||||||
|
static::assertSame($currentDay->getTimestamp(), $data['day']);
|
||||||
|
static::assertEmpty($data['previousday']);
|
||||||
|
static::assertEmpty($data['nextday']);
|
||||||
|
|
||||||
static::assertArrayHasKey('linksToDisplay', $data);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
static::assertCount(1, $data['linksToDisplay']);
|
}
|
||||||
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
|
||||||
static::assertSame($currentDay->getTimestamp(), $data['day']);
|
|
||||||
static::assertEmpty($data['previousday']);
|
|
||||||
static::assertEmpty($data['nextday']);
|
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
});
|
});
|
||||||
|
@ -281,7 +283,7 @@ public function testValidIndexControllerInvokeHeightAdjustment(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -333,7 +335,7 @@ public function testValidIndexControllerInvokeNoBookmark(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Front\Exception\ShaarliFrontException;
|
use Shaarli\Front\Exception\ShaarliFrontException;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
use Slim\Http\Uri;
|
use Slim\Http\Uri;
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Feed\FeedBuilder;
|
use Shaarli\Feed\FeedBuilder;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
@ -45,14 +45,16 @@ public function testDefaultRssController(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_feed'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||||
static::assertSame('render_feed', $hook);
|
if ('render_feed' === $hook) {
|
||||||
static::assertSame('data', $data['content']);
|
static::assertSame('data', $data['content']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
static::assertSame('feed.rss', $param['target']);
|
static::assertSame('feed.rss', $param['target']);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -84,14 +86,16 @@ public function testDefaultAtomController(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_feed'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||||
static::assertSame('render_feed', $hook);
|
if ('render_feed' === $hook) {
|
||||||
static::assertSame('data', $data['content']);
|
static::assertSame('data', $data['content']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
static::assertSame('feed.atom', $param['target']);
|
static::assertSame('feed.atom', $param['target']);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -124,14 +128,16 @@ public function testAtomControllerWithParameters(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_feed'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||||
static::assertSame('render_feed', $hook);
|
if ('render_feed' === $hook) {
|
||||||
static::assertSame('data', $data['content']);
|
static::assertSame('data', $data['content']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
static::assertSame('feed.atom', $param['target']);
|
static::assertSame('feed.atom', $param['target']);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
|
||||||
use Shaarli\Bookmark\BookmarkServiceInterface;
|
use Shaarli\Bookmark\BookmarkServiceInterface;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Container\ShaarliTestContainer;
|
use Shaarli\Container\ShaarliTestContainer;
|
||||||
|
@ -115,5 +114,5 @@ protected static function generateString(int $length): string
|
||||||
/**
|
/**
|
||||||
* Force to be used in PHPUnit context.
|
* Force to be used in PHPUnit context.
|
||||||
*/
|
*/
|
||||||
protected abstract function createMock($originalClassName): MockObject;
|
protected abstract function isInTestsContext(): bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\AlreadyInstalledException;
|
use Shaarli\Front\Exception\AlreadyInstalledException;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\LoginBannedException;
|
use Shaarli\Front\Exception\LoginBannedException;
|
||||||
use Shaarli\Front\Exception\WrongTokenException;
|
use Shaarli\Front\Exception\WrongTokenException;
|
||||||
use Shaarli\Render\TemplatePage;
|
use Shaarli\Render\TemplatePage;
|
||||||
use Shaarli\Security\CookieManager;
|
use Shaarli\Security\CookieManager;
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Front\Exception\ThumbnailsDisabledException;
|
use Shaarli\Front\Exception\ThumbnailsDisabledException;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Shaarli\Thumbnailer;
|
use Shaarli\Thumbnailer;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
@ -67,15 +67,17 @@ public function testValidControllerInvokeDefault(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_picwall'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_picwall', $hook);
|
if ('render_picwall' === $hook) {
|
||||||
static::assertArrayHasKey('linksToDisplay', $data);
|
static::assertArrayHasKey('linksToDisplay', $data);
|
||||||
static::assertCount(2, $data['linksToDisplay']);
|
static::assertCount(2, $data['linksToDisplay']);
|
||||||
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
||||||
static::assertSame(3, $data['linksToDisplay'][1]['id']);
|
static::assertSame(3, $data['linksToDisplay'][1]['id']);
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Security\SessionManager;
|
use Shaarli\Security\SessionManager;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\BookmarkFilter;
|
use Shaarli\Bookmark\BookmarkFilter;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\BookmarkFilter;
|
use Shaarli\Bookmark\BookmarkFilter;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
@ -53,14 +53,16 @@ public function testValidCloudControllerInvokeDefault(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_tagcloud'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_tagcloud', $hook);
|
if ('render_tagcloud' === $hook) {
|
||||||
static::assertSame('', $data['search_tags']);
|
static::assertSame('', $data['search_tags']);
|
||||||
static::assertCount(3, $data['tags']);
|
static::assertCount(3, $data['tags']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
@ -124,14 +126,16 @@ public function testValidCloudControllerInvokeWithParameters(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_tagcloud'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('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;
|
||||||
})
|
})
|
||||||
|
@ -175,14 +179,16 @@ public function testEmptyCloud(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_tagcloud'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_tagcloud', $hook);
|
if ('render_tagcloud' === $hook) {
|
||||||
static::assertSame('', $data['search_tags']);
|
static::assertSame('', $data['search_tags']);
|
||||||
static::assertCount(0, $data['tags']);
|
static::assertCount(0, $data['tags']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
@ -227,14 +233,16 @@ public function testValidListControllerInvokeDefault(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_taglist'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_taglist', $hook);
|
if ('render_taglist' === $hook) {
|
||||||
static::assertSame('', $data['search_tags']);
|
static::assertSame('', $data['search_tags']);
|
||||||
static::assertCount(3, $data['tags']);
|
static::assertCount(3, $data['tags']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
@ -297,14 +305,16 @@ public function testValidListControllerInvokeWithParameters(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_taglist'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_taglist', $hook);
|
if ('render_taglist' === $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;
|
||||||
})
|
})
|
||||||
|
@ -344,14 +354,16 @@ public function testEmptyList(): void
|
||||||
|
|
||||||
// Make sure that PluginManager hook is triggered
|
// Make sure that PluginManager hook is triggered
|
||||||
$this->container->pluginManager
|
$this->container->pluginManager
|
||||||
->expects(static::at(0))
|
->expects(static::atLeastOnce())
|
||||||
->method('executeHooks')
|
->method('executeHooks')
|
||||||
|
->withConsecutive(['render_taglist'])
|
||||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||||
static::assertSame('render_taglist', $hook);
|
if ('render_taglist' === $hook) {
|
||||||
static::assertSame('', $data['search_tags']);
|
static::assertSame('', $data['search_tags']);
|
||||||
static::assertCount(0, $data['tags']);
|
static::assertCount(0, $data['tags']);
|
||||||
|
|
||||||
static::assertArrayHasKey('loggedin', $param);
|
static::assertArrayHasKey('loggedin', $param);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Front\Controller\Visitor;
|
namespace Shaarli\Front\Controller\Visitor;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for client_ip_id()
|
* Unitary tests for client_ip_id()
|
||||||
*/
|
*/
|
||||||
class ClientIpIdTest extends \PHPUnit\Framework\TestCase
|
class ClientIpIdTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get a remote client ID based on its IP
|
* Get a remote client ID based on its IP
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for get_http_response()
|
* Unitary tests for get_http_response()
|
||||||
*/
|
*/
|
||||||
class GetHttpUrlTest extends \PHPUnit\Framework\TestCase
|
class GetHttpUrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get an invalid local URL
|
* Get an invalid local URL
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for getIpAddressFromProxy()
|
* Unitary tests for getIpAddressFromProxy()
|
||||||
*/
|
*/
|
||||||
class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase
|
class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Http;
|
namespace Shaarli\Http;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
require_once 'application/http/HttpUtils.php';
|
require_once 'application/http/HttpUtils.php';
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Shaarli\Http;
|
namespace Shaarli\Http;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval.
|
* Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval.
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Test class for is_https() function.
|
* Test class for is_https() function.
|
||||||
*/
|
*/
|
||||||
class IsHttpsTest extends \PHPUnit\Framework\TestCase
|
class IsHttpsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for page_url()
|
* Unitary tests for page_url()
|
||||||
*/
|
*/
|
||||||
class PageUrlTest extends \PHPUnit\Framework\TestCase
|
class PageUrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* If on the main page, remove "index.php" from the URL resource
|
* If on the main page, remove "index.php" from the URL resource
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for server_url()
|
* Unitary tests for server_url()
|
||||||
*/
|
*/
|
||||||
class ServerUrlTest extends \PHPUnit\Framework\TestCase
|
class ServerUrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Detect if the server uses SSL
|
* Detect if the server uses SSL
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for URL utilities
|
* Unitary tests for URL utilities
|
||||||
*/
|
*/
|
||||||
class UrlTest extends \PHPUnit\Framework\TestCase
|
class UrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
// base URL for tests
|
// base URL for tests
|
||||||
protected static $baseUrl = 'http://domain.tld:3000';
|
protected static $baseUrl = 'http://domain.tld:3000';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
require_once 'application/http/UrlUtils.php';
|
require_once 'application/http/UrlUtils.php';
|
||||||
|
|
||||||
class CleanupUrlTest extends \PHPUnit\Framework\TestCase
|
class CleanupUrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string reference URL
|
* @var string reference URL
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
require_once 'application/http/UrlUtils.php';
|
require_once 'application/http/UrlUtils.php';
|
||||||
|
|
||||||
class GetUrlSchemeTest extends \PHPUnit\Framework\TestCase
|
class GetUrlSchemeTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get empty scheme string for empty UrlUtils
|
* Get empty scheme string for empty UrlUtils
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for unparse_url()
|
* Unitary tests for unparse_url()
|
||||||
*/
|
*/
|
||||||
class UnparseUrlTest extends \PHPUnit\Framework\TestCase
|
class UnparseUrlTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Thanks for building nothing
|
* Thanks for building nothing
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* Test whitelist_protocols() function of UrlUtils.
|
* Test whitelist_protocols() function of UrlUtils.
|
||||||
*/
|
*/
|
||||||
class WhitelistProtocolsTest extends \PHPUnit\Framework\TestCase
|
class WhitelistProtocolsTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Test whitelist_protocols() on a note (relative URL).
|
* Test whitelist_protocols() on a note (relative URL).
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
*
|
*
|
||||||
* @package Shaarli
|
* @package Shaarli
|
||||||
*/
|
*/
|
||||||
class LanguagesFrTest extends \PHPUnit\Framework\TestCase
|
class LanguagesFrTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Config file path (without extension).
|
* @var string Config file path (without extension).
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
namespace Shaarli\Legacy;
|
namespace Shaarli\Legacy;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
|
use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\Request;
|
use Slim\Http\Request;
|
||||||
use Slim\Http\Response;
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
/**
|
/**
|
||||||
* Unitary tests for LegacyLinkDBTest
|
* Unitary tests for LegacyLinkDBTest
|
||||||
*/
|
*/
|
||||||
class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
|
class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
// datastore to test write operations
|
// datastore to test write operations
|
||||||
protected static $testDatastore = 'sandbox/datastore.php';
|
protected static $testDatastore = 'sandbox/datastore.php';
|
||||||
|
@ -99,11 +99,10 @@ public function testConstructLoggedOut()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to instantiate a LinkDB whereas the datastore is not writable
|
* Attempt to instantiate a LinkDB whereas the datastore is not writable
|
||||||
*
|
|
||||||
* @expectedException Shaarli\Exceptions\IOException
|
|
||||||
*/
|
*/
|
||||||
public function testConstructDatastoreNotWriteable()
|
public function testConstructDatastoreNotWriteable()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Shaarli\Exceptions\IOException::class);
|
||||||
$this->expectExceptionMessageRegExp('/Error accessing "null"/');
|
$this->expectExceptionMessageRegExp('/Error accessing "null"/');
|
||||||
|
|
||||||
new LegacyLinkDB('null/store.db', false, false);
|
new LegacyLinkDB('null/store.db', false, false);
|
||||||
|
@ -258,7 +257,7 @@ public function testGetKnownLinkFromURL()
|
||||||
$link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/');
|
$link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/');
|
||||||
|
|
||||||
$this->assertNotEquals(false, $link);
|
$this->assertNotEquals(false, $link);
|
||||||
$this->assertContains(
|
$this->assertContainsPolyfill(
|
||||||
'A free software media publishing platform',
|
'A free software media publishing platform',
|
||||||
$link['description']
|
$link['description']
|
||||||
);
|
);
|
||||||
|
@ -471,9 +470,9 @@ public function testRenameTagMultiple()
|
||||||
|
|
||||||
$res = $linkDB->renameTag('cartoon', 'Taz');
|
$res = $linkDB->renameTag('cartoon', 'Taz');
|
||||||
$this->assertEquals(3, count($res));
|
$this->assertEquals(3, count($res));
|
||||||
$this->assertContains(' Taz ', $linkDB[4]['tags']);
|
$this->assertContainsPolyfill(' Taz ', $linkDB[4]['tags']);
|
||||||
$this->assertContains(' Taz ', $linkDB[1]['tags']);
|
$this->assertContainsPolyfill(' Taz ', $linkDB[1]['tags']);
|
||||||
$this->assertContains(' Taz ', $linkDB[0]['tags']);
|
$this->assertContainsPolyfill(' Taz ', $linkDB[0]['tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -513,7 +512,7 @@ public function testDeleteTag()
|
||||||
|
|
||||||
$res = $linkDB->renameTag('cartoon', null);
|
$res = $linkDB->renameTag('cartoon', null);
|
||||||
$this->assertEquals(3, count($res));
|
$this->assertEquals(3, count($res));
|
||||||
$this->assertNotContains('cartoon', $linkDB[4]['tags']);
|
$this->assertNotContainsPolyfill('cartoon', $linkDB[4]['tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
/**
|
/**
|
||||||
* Class LegacyLinkFilterTest.
|
* Class LegacyLinkFilterTest.
|
||||||
*/
|
*/
|
||||||
class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
|
class LegacyLinkFilterTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Test datastore path.
|
* @var string Test datastore path.
|
||||||
|
@ -197,10 +197,10 @@ public function testFilterUnknownDay()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use an invalid date format
|
* Use an invalid date format
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testFilterInvalidDayWithChars()
|
public function testFilterInvalidDayWithChars()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
||||||
|
|
||||||
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away');
|
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away');
|
||||||
|
@ -208,10 +208,10 @@ public function testFilterInvalidDayWithChars()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use an invalid date format
|
* Use an invalid date format
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testFilterInvalidDayDigits()
|
public function testFilterInvalidDayDigits()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
$this->expectExceptionMessageRegExp('/Invalid date format/');
|
||||||
|
|
||||||
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20');
|
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20');
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* Class UpdaterTest.
|
* Class UpdaterTest.
|
||||||
* Runs unit tests against the updater class.
|
* Runs unit tests against the updater class.
|
||||||
*/
|
*/
|
||||||
class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
|
class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string Path to test datastore.
|
* @var string Path to test datastore.
|
||||||
|
@ -80,11 +80,10 @@ public function testReadWriteUpdatesFile()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test errors in UpdaterUtils::write_updates_file(): empty updates file.
|
* Test errors in UpdaterUtils::write_updates_file(): empty updates file.
|
||||||
*
|
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testWriteEmptyUpdatesFile()
|
public function testWriteEmptyUpdatesFile()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
|
||||||
|
|
||||||
UpdaterUtils::write_updates_file('', array('test'));
|
UpdaterUtils::write_updates_file('', array('test'));
|
||||||
|
@ -92,11 +91,10 @@ public function testWriteEmptyUpdatesFile()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
|
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
|
||||||
*
|
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testWriteUpdatesFileNotWritable()
|
public function testWriteUpdatesFileNotWritable()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Unable to write(.*)/');
|
$this->expectExceptionMessageRegExp('/Unable to write(.*)/');
|
||||||
|
|
||||||
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
|
||||||
|
@ -725,7 +723,7 @@ public function testUpdateMethodWebThumbnailerEnabled()
|
||||||
$this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode'));
|
$this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode'));
|
||||||
$this->assertEquals(125, $this->conf->get('thumbnails.width'));
|
$this->assertEquals(125, $this->conf->get('thumbnails.width'));
|
||||||
$this->assertEquals(90, $this->conf->get('thumbnails.height'));
|
$this->assertEquals(90, $this->conf->get('thumbnails.height'));
|
||||||
$this->assertContains('You have enabled or changed thumbnails', $_SESSION['warnings'][0]);
|
$this->assertContainsPolyfill('You have enabled or changed thumbnails', $_SESSION['warnings'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
namespace Shaarli\Netscape;
|
namespace Shaarli\Netscape;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Shaarli\Bookmark\BookmarkFileService;
|
use Shaarli\Bookmark\BookmarkFileService;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\Formatter\BookmarkFormatter;
|
use Shaarli\Formatter\BookmarkFormatter;
|
||||||
use Shaarli\Formatter\FormatterFactory;
|
use Shaarli\Formatter\FormatterFactory;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
|
|
||||||
require_once 'tests/utils/ReferenceLinkDB.php';
|
require_once 'tests/utils/ReferenceLinkDB.php';
|
||||||
|
|
||||||
|
@ -77,10 +77,10 @@ public function setUp(): void
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to export an invalid link selection
|
* Attempt to export an invalid link selection
|
||||||
* @expectedException Exception
|
|
||||||
*/
|
*/
|
||||||
public function testFilterAndFormatInvalid()
|
public function testFilterAndFormatInvalid()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
$this->expectExceptionMessageRegExp('/Invalid export selection/');
|
$this->expectExceptionMessageRegExp('/Invalid export selection/');
|
||||||
|
|
||||||
$this->netscapeBookmarkUtils->filterAndFormat(
|
$this->netscapeBookmarkUtils->filterAndFormat(
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
namespace Shaarli\Netscape;
|
namespace Shaarli\Netscape;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
use Psr\Http\Message\UploadedFileInterface;
|
||||||
use Shaarli\Bookmark\Bookmark;
|
use Shaarli\Bookmark\Bookmark;
|
||||||
use Shaarli\Bookmark\BookmarkFileService;
|
use Shaarli\Bookmark\BookmarkFileService;
|
||||||
use Shaarli\Bookmark\BookmarkFilter;
|
use Shaarli\Bookmark\BookmarkFilter;
|
||||||
use Shaarli\Config\ConfigManager;
|
use Shaarli\Config\ConfigManager;
|
||||||
use Shaarli\History;
|
use Shaarli\History;
|
||||||
|
use Shaarli\TestCase;
|
||||||
use Slim\Http\UploadedFile;
|
use Slim\Http\UploadedFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
/**
|
/**
|
||||||
* Unit test for the Addlink toolbar plugin
|
* Unit test for the Addlink toolbar plugin
|
||||||
*/
|
*/
|
||||||
class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
|
class PluginAddlinkTest extends \Shaarli\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Reset plugin path.
|
* Reset plugin path.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue