Compatibility with PHPUnit 9
This commit is contained in:
parent
2b7a7bc928
commit
a5a9cf23ac
112 changed files with 351 additions and 253 deletions
|
@ -5,6 +5,9 @@ matrix:
|
|||
# jobs for each supported php version
|
||||
- language: php
|
||||
php: nightly # PHP 8.0
|
||||
install:
|
||||
- composer self-update --2
|
||||
- composer update --ignore-platform-req=php
|
||||
- language: php
|
||||
php: 7.4
|
||||
- language: php
|
||||
|
@ -45,7 +48,6 @@ cache:
|
|||
|
||||
install:
|
||||
# install/update composer and php dependencies
|
||||
- if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then export TRAVIS_PHP_VERSION="8.0.0"; fi
|
||||
- composer config --unset platform && composer config platform.php $TRAVIS_PHP_VERSION
|
||||
- composer update
|
||||
|
||||
|
|
|
@ -27,9 +27,8 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"roave/security-advisories": "dev-master",
|
||||
"phpunit/phpcov": "*",
|
||||
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
|
||||
"squizlabs/php_codesniffer": "3.*"
|
||||
"squizlabs/php_codesniffer": "3.*",
|
||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Allows fetching web pages and thumbnails in a more robust way",
|
||||
|
|
|
@ -8,7 +8,7 @@ require_once 'tests/utils/FakeApplicationUtils.php';
|
|||
/**
|
||||
* Unitary tests for Shaarli utilities
|
||||
*/
|
||||
class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase
|
||||
class ApplicationUtilsTest extends \Shaarli\TestCase
|
||||
{
|
||||
protected static $testUpdateFile = 'sandbox/update.txt';
|
||||
protected static $testVersion = '0.5.0';
|
||||
|
|
|
@ -9,7 +9,7 @@ use Exception;
|
|||
*
|
||||
* Test file utility class.
|
||||
*/
|
||||
class FileUtilsTest extends \PHPUnit\Framework\TestCase
|
||||
class FileUtilsTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Test file path.
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
namespace Shaarli;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
|
||||
class HistoryTest extends \PHPUnit\Framework\TestCase
|
||||
class HistoryTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string History file path
|
||||
|
|
|
@ -7,7 +7,7 @@ use Shaarli\Config\ConfigManager;
|
|||
/**
|
||||
* Class LanguagesTest.
|
||||
*/
|
||||
class LanguagesTest extends \PHPUnit\Framework\TestCase
|
||||
class LanguagesTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Config file path (without extension).
|
||||
|
|
|
@ -6,7 +6,7 @@ use Shaarli\Config\ConfigManager;
|
|||
/**
|
||||
* Unit tests for Plugins
|
||||
*/
|
||||
class PluginManagerTest extends \PHPUnit\Framework\TestCase
|
||||
class PluginManagerTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Path to tests plugin.
|
||||
|
|
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;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use WebThumbnailer\Application\ConfigManager as WTConfigManager;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ require_once 'application/TimeZone.php';
|
|||
/**
|
||||
* Unitary tests for timezone utilities
|
||||
*/
|
||||
class TimeZoneTest extends PHPUnit\Framework\TestCase
|
||||
class TimeZoneTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var array of timezones
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/Languages.php';
|
|||
/**
|
||||
* Unitary tests for Shaarli utilities
|
||||
*/
|
||||
class UtilsTest extends PHPUnit\Framework\TestCase
|
||||
class UtilsTest extends \Shaarli\TestCase
|
||||
{
|
||||
// Log file
|
||||
protected static $testLogFile = 'tests.log';
|
||||
|
|
|
@ -18,7 +18,7 @@ use Slim\Http\Response;
|
|||
*
|
||||
* @package Api
|
||||
*/
|
||||
class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
||||
class ApiMiddlewareTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
@ -26,7 +26,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
protected static $testDatastore = 'sandbox/datastore.php';
|
||||
|
||||
/**
|
||||
* @var \ConfigManager instance
|
||||
* @var ConfigManager instance
|
||||
*/
|
||||
protected $conf;
|
||||
|
||||
|
@ -109,7 +109,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(401, $response->getStatusCode());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
$this->assertEquals('Not authorized: API is disabled', $body->message);
|
||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
||||
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(401, $response->getStatusCode());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
$this->assertEquals('Not authorized: JWT token not provided', $body->message);
|
||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
||||
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(401, $response->getStatusCode());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +180,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(401, $response->getStatusCode());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
$this->assertEquals('Not authorized: Invalid JWT header', $body->message);
|
||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
||||
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,6 +206,6 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
|
|||
$this->assertEquals(401, $response->getStatusCode());
|
||||
$body = json_decode((string) $response->getBody());
|
||||
$this->assertEquals('Not authorized: Malformed JWT token', $body->message);
|
||||
$this->assertContains('ApiAuthorizationException', $body->stacktrace);
|
||||
$this->assertContainsPolyfill('ApiAuthorizationException', $body->stacktrace);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use Shaarli\Http\Base64Url;
|
|||
/**
|
||||
* Class ApiUtilsTest
|
||||
*/
|
||||
class ApiUtilsTest extends \PHPUnit\Framework\TestCase
|
||||
class ApiUtilsTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Force the timezone for ISO datetimes.
|
||||
|
|
|
@ -11,7 +11,7 @@ use Slim\Http\Response;
|
|||
|
||||
require_once 'tests/utils/ReferenceHistory.php';
|
||||
|
||||
class HistoryTest extends \PHPUnit\Framework\TestCase
|
||||
class HistoryTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
|
|
@ -11,7 +11,7 @@ use Slim\Http\Environment;
|
|||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class DeleteLinkTest extends \PHPUnit\Framework\TestCase
|
||||
class DeleteLinkTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -20,7 +20,7 @@ use Slim\Http\Response;
|
|||
*
|
||||
* @package Shaarli\Api\Controllers
|
||||
*/
|
||||
class GetLinkIdTest extends \PHPUnit\Framework\TestCase
|
||||
class GetLinkIdTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -20,7 +20,7 @@ use Slim\Http\Response;
|
|||
*
|
||||
* @package Shaarli\Api\Controllers
|
||||
*/
|
||||
class GetLinksTest extends \PHPUnit\Framework\TestCase
|
||||
class GetLinksTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace Shaarli\Api\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Container;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Request;
|
||||
|
|
|
@ -12,7 +12,7 @@ use Slim\Http\Environment;
|
|||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class PutLinkTest extends \PHPUnit\Framework\TestCase
|
||||
class PutLinkTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -12,7 +12,7 @@ use Slim\Http\Environment;
|
|||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class DeleteTagTest extends \PHPUnit\Framework\TestCase
|
||||
class DeleteTagTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -18,7 +18,7 @@ use Slim\Http\Response;
|
|||
*
|
||||
* @package Shaarli\Api\Controllers
|
||||
*/
|
||||
class GetTagNameTest extends \PHPUnit\Framework\TestCase
|
||||
class GetTagNameTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -17,7 +17,7 @@ use Slim\Http\Response;
|
|||
*
|
||||
* @package Shaarli\Api\Controllers
|
||||
*/
|
||||
class GetTagsTest extends \PHPUnit\Framework\TestCase
|
||||
class GetTagsTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -12,7 +12,7 @@ use Slim\Http\Environment;
|
|||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class PutTagTest extends \PHPUnit\Framework\TestCase
|
||||
class PutTagTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string datastore to test write operations
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
namespace Shaarli\Bookmark;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Exception\InvalidBookmarkException;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkArrayTest
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
namespace Shaarli\Bookmark;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReferenceLinkDB;
|
||||
use ReflectionClass;
|
||||
use Shaarli;
|
||||
|
@ -14,6 +13,7 @@ use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
|||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Formatter\BookmarkMarkdownFormatter;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Unitary tests for LegacyLinkDBTest
|
||||
|
@ -748,7 +748,7 @@ class BookmarkFileServiceTest extends TestCase
|
|||
$link = $this->publicLinkDB->findByUrl('http://mediagoblin.org/');
|
||||
|
||||
$this->assertNotEquals(false, $link);
|
||||
$this->assertContains(
|
||||
$this->assertContainsPolyfill(
|
||||
'A free software media publishing platform',
|
||||
$link->getDescription()
|
||||
);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace Shaarli\Bookmark;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReferenceLinkDB;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkFilterTest.
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Shaarli\Bookmark;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkInitializerTest
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Shaarli\Bookmark;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Exception\InvalidBookmarkException;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkTest
|
||||
|
@ -150,7 +150,7 @@ class BookmarkTest extends TestCase
|
|||
$exception = $e;
|
||||
}
|
||||
$this->assertNotNull($exception);
|
||||
$this->assertContains('- ID: '. PHP_EOL, $exception->getMessage());
|
||||
$this->assertContainsPolyfill('- ID: '. PHP_EOL, $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +169,7 @@ class BookmarkTest extends TestCase
|
|||
$exception = $e;
|
||||
}
|
||||
$this->assertNotNull($exception);
|
||||
$this->assertContains('- ID: str'. PHP_EOL, $exception->getMessage());
|
||||
$this->assertContainsPolyfill('- ID: str'. PHP_EOL, $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +188,7 @@ class BookmarkTest extends TestCase
|
|||
$exception = $e;
|
||||
}
|
||||
$this->assertNotNull($exception);
|
||||
$this->assertContains('- ShortUrl: '. PHP_EOL, $exception->getMessage());
|
||||
$this->assertContainsPolyfill('- ShortUrl: '. PHP_EOL, $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +207,7 @@ class BookmarkTest extends TestCase
|
|||
$exception = $e;
|
||||
}
|
||||
$this->assertNotNull($exception);
|
||||
$this->assertContains('- Created: '. PHP_EOL, $exception->getMessage());
|
||||
$this->assertContainsPolyfill('- Created: '. PHP_EOL, $exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +226,7 @@ class BookmarkTest extends TestCase
|
|||
$exception = $e;
|
||||
}
|
||||
$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;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
require_once 'tests/utils/CurlUtils.php';
|
||||
|
||||
|
@ -437,13 +437,13 @@ class LinkUtilsTest extends TestCase
|
|||
カタカナ #カタカナ」カタカナ\n';
|
||||
$autolinkedDescription = hashtag_autolink($rawDescription, $index);
|
||||
|
||||
$this->assertContains($this->getHashtagLink('hashtag', $index), $autolinkedDescription);
|
||||
$this->assertNotContains(' #hashtag', $autolinkedDescription);
|
||||
$this->assertNotContains('>#nothashtag', $autolinkedDescription);
|
||||
$this->assertContains($this->getHashtagLink('ашок', $index), $autolinkedDescription);
|
||||
$this->assertContains($this->getHashtagLink('カタカナ', $index), $autolinkedDescription);
|
||||
$this->assertContains($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription);
|
||||
$this->assertNotContains($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription);
|
||||
$this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription);
|
||||
$this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
|
||||
$this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
|
||||
$this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription);
|
||||
$this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription);
|
||||
$this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription);
|
||||
$this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,9 +454,9 @@ class LinkUtilsTest extends TestCase
|
|||
$rawDescription = 'blabla #hashtag x#nothashtag';
|
||||
$autolinkedDescription = hashtag_autolink($rawDescription);
|
||||
|
||||
$this->assertContains($this->getHashtagLink('hashtag'), $autolinkedDescription);
|
||||
$this->assertNotContains(' #hashtag', $autolinkedDescription);
|
||||
$this->assertNotContains('>#nothashtag', $autolinkedDescription);
|
||||
$this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription);
|
||||
$this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
|
||||
$this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ require_once 'application/bookmark/LinkUtils.php';
|
|||
require_once 'application/Utils.php';
|
||||
require_once 'application/http/UrlUtils.php';
|
||||
require_once 'application/http/HttpUtils.php';
|
||||
require_once 'tests/TestCase.php';
|
||||
require_once 'tests/container/ShaarliTestContainer.php';
|
||||
require_once 'tests/front/controller/visitor/FrontControllerMockHelper.php';
|
||||
require_once 'tests/front/controller/admin/FrontAdminControllerMockHelper.php';
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Shaarli\Config;
|
|||
/**
|
||||
* Class ConfigJsonTest
|
||||
*/
|
||||
class ConfigJsonTest extends \PHPUnit\Framework\TestCase
|
||||
class ConfigJsonTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigJson
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Shaarli\Config;
|
|||
* Note: it only test the manager with ConfigJson,
|
||||
* 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
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Shaarli\Config;
|
|||
* which are kept between tests.
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class ConfigPhpTest extends \PHPUnit\Framework\TestCase
|
||||
class ConfigPhpTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ConfigPhp
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once 'application/config/ConfigPlugin.php';
|
|||
/**
|
||||
* 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.
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Container;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\BookmarkServiceInterface;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Feed\FeedBuilder;
|
||||
|
@ -20,6 +19,7 @@ use Shaarli\Render\PageCacheManager;
|
|||
use Shaarli\Security\CookieManager;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Shaarli\Updater\Updater;
|
||||
use Slim\Http\Environment;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Shaarli\Feed;
|
|||
/**
|
||||
* Unitary tests for cached pages
|
||||
*/
|
||||
class CachedPageTest extends \PHPUnit\Framework\TestCase
|
||||
class CachedPageTest extends \Shaarli\TestCase
|
||||
{
|
||||
// test cache directory
|
||||
protected static $testCacheDir = 'sandbox/pagecache';
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Shaarli\Feed;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReferenceLinkDB;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
|
@ -11,6 +10,7 @@ use Shaarli\Bookmark\LinkDB;
|
|||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Formatter\FormatterFactory;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* FeedBuilderTest class.
|
||||
|
@ -97,9 +97,9 @@ class FeedBuilderTest extends TestCase
|
|||
$pub = DateTime::createFromFormat(DateTime::RSS, $link['pub_iso_date']);
|
||||
$up = DateTime::createFromFormat(DateTime::ATOM, $link['up_iso_date']);
|
||||
$this->assertEquals($pub, $up);
|
||||
$this->assertContains('Stallman has a beard', $link['description']);
|
||||
$this->assertContains('Permalink', $link['description']);
|
||||
$this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
|
||||
$this->assertContainsPolyfill('Stallman has a beard', $link['description']);
|
||||
$this->assertContainsPolyfill('Permalink', $link['description']);
|
||||
$this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']);
|
||||
$this->assertEquals(1, count($link['taglist']));
|
||||
$this->assertEquals('sTuff', $link['taglist'][0]);
|
||||
|
||||
|
@ -201,16 +201,16 @@ class FeedBuilderTest extends TestCase
|
|||
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114651'), $link['created']);
|
||||
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['guid']);
|
||||
$this->assertEquals('http://host.tld/shaare/WDWyig', $link['url']);
|
||||
$this->assertContains('Direct link', $link['description']);
|
||||
$this->assertContains('http://host.tld/shaare/WDWyig', $link['description']);
|
||||
$this->assertContainsPolyfill('Direct link', $link['description']);
|
||||
$this->assertContainsPolyfill('http://host.tld/shaare/WDWyig', $link['description']);
|
||||
// Second link is a direct link
|
||||
$link = $data['links'][array_keys($data['links'])[1]];
|
||||
$this->assertEquals(8, $link['id']);
|
||||
$this->assertEquals(DateTime::createFromFormat(Bookmark::LINK_DATE_FORMAT, '20150310_114633'), $link['created']);
|
||||
$this->assertEquals('http://host.tld/shaare/RttfEw', $link['guid']);
|
||||
$this->assertEquals('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['url']);
|
||||
$this->assertContains('Direct link', $link['description']);
|
||||
$this->assertContains('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']);
|
||||
$this->assertContainsPolyfill('Direct link', $link['description']);
|
||||
$this->assertContainsPolyfill('https://static.fsf.org/nosvn/faif-2.0.pdf', $link['description']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,6 +274,6 @@ class FeedBuilderTest extends TestCase
|
|||
$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['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;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkDefaultFormatterTest
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace Shaarli\Formatter;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkMarkdownFormatterTest
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace Shaarli\Formatter;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class BookmarkRawFormatterTest
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Shaarli\Formatter;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Class FormatterFactoryTest
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Container\ShaarliContainer;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Updater\Updater;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Container\ShaarliContainer;
|
||||
use Shaarli\Front\Exception\LoginBannedException;
|
||||
|
@ -12,6 +11,7 @@ use Shaarli\Front\Exception\UnauthorizedException;
|
|||
use Shaarli\Render\PageBuilder;
|
||||
use Shaarli\Render\PageCacheManager;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Updater\Updater;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Formatter\BookmarkFormatter;
|
||||
use Shaarli\Formatter\BookmarkRawFormatter;
|
||||
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Shaarli\Netscape\NetscapeBookmarkUtils;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use Slim\Http\UploadedFile;
|
||||
|
|
|
@ -4,10 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Security\CookieManager;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\Formatter\BookmarkFormatter;
|
||||
|
@ -14,6 +13,7 @@ use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
|||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\Formatter\BookmarkFormatter;
|
||||
|
@ -13,6 +12,7 @@ use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
|||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
@ -96,12 +96,14 @@ class DisplayCreateFormTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_editlink'], ['render_includes'])
|
||||
->willReturnCallback(function (string $hook, array $data) use ($remoteTitle, $remoteDesc): array {
|
||||
static::assertSame('render_editlink', $hook);
|
||||
static::assertSame($remoteTitle, $data['link']['title']);
|
||||
static::assertSame($remoteDesc, $data['link']['description']);
|
||||
if ('render_editlink' === $hook) {
|
||||
static::assertSame($remoteTitle, $data['link']['title']);
|
||||
static::assertSame($remoteDesc, $data['link']['description']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||
use Shaarli\Front\Controller\Admin\ManageShaareController;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin\ManageShaareControllerTest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
|
||||
|
@ -12,6 +11,7 @@ use Shaarli\Front\Controller\Admin\ManageShaareController;
|
|||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Http\HttpAccess;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
@ -88,17 +88,18 @@ class SaveBookmarkTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['save_link'])
|
||||
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
||||
static::assertSame('save_link', $hook);
|
||||
|
||||
static::assertSame($id, $data['id']);
|
||||
static::assertSame($parameters['lf_url'], $data['url']);
|
||||
static::assertSame($parameters['lf_title'], $data['title']);
|
||||
static::assertSame($parameters['lf_description'], $data['description']);
|
||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||
static::assertTrue($data['private']);
|
||||
if ('save_link' === $hook) {
|
||||
static::assertSame($id, $data['id']);
|
||||
static::assertSame($parameters['lf_url'], $data['url']);
|
||||
static::assertSame($parameters['lf_title'], $data['title']);
|
||||
static::assertSame($parameters['lf_description'], $data['description']);
|
||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||
static::assertTrue($data['private']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -174,17 +175,18 @@ class SaveBookmarkTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['save_link'])
|
||||
->willReturnCallback(function (string $hook, array $data) use ($parameters, $id): array {
|
||||
static::assertSame('save_link', $hook);
|
||||
|
||||
static::assertSame($id, $data['id']);
|
||||
static::assertSame($parameters['lf_url'], $data['url']);
|
||||
static::assertSame($parameters['lf_title'], $data['title']);
|
||||
static::assertSame($parameters['lf_description'], $data['description']);
|
||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||
static::assertTrue($data['private']);
|
||||
if ('save_link' === $hook) {
|
||||
static::assertSame($id, $data['id']);
|
||||
static::assertSame($parameters['lf_url'], $data['url']);
|
||||
static::assertSame($parameters['lf_title'], $data['title']);
|
||||
static::assertSame($parameters['lf_description'], $data['description']);
|
||||
static::assertSame($parameters['lf_tags'], $data['tags']);
|
||||
static::assertTrue($data['private']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\BookmarkFilter;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\OpenShaarliPasswordException;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Plugin\PluginManager;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Admin;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Security\LoginManager;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
|
|
@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Feed\CachedPage;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
@ -78,19 +78,20 @@ class DailyControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_daily'])
|
||||
->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::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);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -203,19 +204,20 @@ class DailyControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_daily'])
|
||||
->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::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);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
@ -281,7 +283,7 @@ class DailyControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
return $data;
|
||||
|
@ -333,7 +335,7 @@ class DailyControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
return $data;
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Front\Exception\ShaarliFrontException;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use Slim\Http\Uri;
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Feed\FeedBuilder;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
@ -45,14 +45,16 @@ class FeedControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_feed'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||
static::assertSame('render_feed', $hook);
|
||||
static::assertSame('data', $data['content']);
|
||||
if ('render_feed' === $hook) {
|
||||
static::assertSame('data', $data['content']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.rss', $param['target']);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.rss', $param['target']);
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
|
@ -84,14 +86,16 @@ class FeedControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_feed'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||
static::assertSame('render_feed', $hook);
|
||||
static::assertSame('data', $data['content']);
|
||||
if ('render_feed' === $hook) {
|
||||
static::assertSame('data', $data['content']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.atom', $param['target']);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.atom', $param['target']);
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
|
@ -124,14 +128,16 @@ class FeedControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_feed'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): void {
|
||||
static::assertSame('render_feed', $hook);
|
||||
static::assertSame('data', $data['content']);
|
||||
if ('render_feed' === $hook) {
|
||||
static::assertSame('data', $data['content']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.atom', $param['target']);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertSame('feed.atom', $param['target']);
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Shaarli\Bookmark\BookmarkServiceInterface;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Container\ShaarliTestContainer;
|
||||
|
@ -115,5 +114,5 @@ trait FrontControllerMockHelper
|
|||
/**
|
||||
* Force to be used in PHPUnit context.
|
||||
*/
|
||||
protected abstract function createMock($originalClassName): MockObject;
|
||||
protected abstract function isInTestsContext(): bool;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\AlreadyInstalledException;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\LoginBannedException;
|
||||
use Shaarli\Front\Exception\WrongTokenException;
|
||||
use Shaarli\Render\TemplatePage;
|
||||
use Shaarli\Security\CookieManager;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Front\Exception\ThumbnailsDisabledException;
|
||||
use Shaarli\TestCase;
|
||||
use Shaarli\Thumbnailer;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
@ -67,15 +67,17 @@ class PictureWallControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_picwall'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_picwall', $hook);
|
||||
static::assertArrayHasKey('linksToDisplay', $data);
|
||||
static::assertCount(2, $data['linksToDisplay']);
|
||||
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
||||
static::assertSame(3, $data['linksToDisplay'][1]['id']);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
if ('render_picwall' === $hook) {
|
||||
static::assertArrayHasKey('linksToDisplay', $data);
|
||||
static::assertCount(2, $data['linksToDisplay']);
|
||||
static::assertSame(1, $data['linksToDisplay'][0]['id']);
|
||||
static::assertSame(3, $data['linksToDisplay'][1]['id']);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Security\SessionManager;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\BookmarkFilter;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\BookmarkFilter;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
@ -53,14 +53,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_tagcloud'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_tagcloud', $hook);
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(3, $data['tags']);
|
||||
if ('render_tagcloud' === $hook) {
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(3, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -124,14 +126,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_tagcloud'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_tagcloud', $hook);
|
||||
static::assertSame('ghi def', $data['search_tags']);
|
||||
static::assertCount(1, $data['tags']);
|
||||
if ('render_tagcloud' === $hook) {
|
||||
static::assertSame('ghi def', $data['search_tags']);
|
||||
static::assertCount(1, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -175,14 +179,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_tagcloud'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_tagcloud', $hook);
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(0, $data['tags']);
|
||||
if ('render_tagcloud' === $hook) {
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(0, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -227,14 +233,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_taglist'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_taglist', $hook);
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(3, $data['tags']);
|
||||
if ('render_taglist' === $hook) {
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(3, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -297,14 +305,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_taglist'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_taglist', $hook);
|
||||
static::assertSame('ghi def', $data['search_tags']);
|
||||
static::assertCount(1, $data['tags']);
|
||||
if ('render_taglist' === $hook) {
|
||||
static::assertSame('ghi def', $data['search_tags']);
|
||||
static::assertCount(1, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
@ -344,14 +354,16 @@ class TagCloudControllerTest extends TestCase
|
|||
|
||||
// Make sure that PluginManager hook is triggered
|
||||
$this->container->pluginManager
|
||||
->expects(static::at(0))
|
||||
->expects(static::atLeastOnce())
|
||||
->method('executeHooks')
|
||||
->withConsecutive(['render_taglist'])
|
||||
->willReturnCallback(function (string $hook, array $data, array $param): array {
|
||||
static::assertSame('render_taglist', $hook);
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(0, $data['tags']);
|
||||
if ('render_taglist' === $hook) {
|
||||
static::assertSame('', $data['search_tags']);
|
||||
static::assertCount(0, $data['tags']);
|
||||
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
static::assertArrayHasKey('loggedin', $param);
|
||||
}
|
||||
|
||||
return $data;
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Front\Controller\Visitor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
/**
|
||||
* 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
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
/**
|
||||
* Unitary tests for get_http_response()
|
||||
*/
|
||||
class GetHttpUrlTest extends \PHPUnit\Framework\TestCase
|
||||
class GetHttpUrlTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Get an invalid local URL
|
||||
|
|
|
@ -7,7 +7,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
/**
|
||||
* Unitary tests for getIpAddressFromProxy()
|
||||
*/
|
||||
class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase
|
||||
class GetIpAdressFromProxyTest extends \Shaarli\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace Shaarli\Http;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
require_once 'application/http/HttpUtils.php';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Http;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
/**
|
||||
* Test index_url with SHAARLI_ROOT_URL defined to override automatic retrieval.
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
*
|
||||
* Test class for is_https() function.
|
||||
*/
|
||||
class IsHttpsTest extends \PHPUnit\Framework\TestCase
|
||||
class IsHttpsTest extends \Shaarli\TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
/**
|
||||
* 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
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/http/HttpUtils.php';
|
|||
/**
|
||||
* Unitary tests for server_url()
|
||||
*/
|
||||
class ServerUrlTest extends \PHPUnit\Framework\TestCase
|
||||
class ServerUrlTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Detect if the server uses SSL
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Shaarli\Http;
|
|||
/**
|
||||
* Unitary tests for URL utilities
|
||||
*/
|
||||
class UrlTest extends \PHPUnit\Framework\TestCase
|
||||
class UrlTest extends \Shaarli\TestCase
|
||||
{
|
||||
// base URL for tests
|
||||
protected static $baseUrl = 'http://domain.tld:3000';
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Shaarli\Http;
|
|||
|
||||
require_once 'application/http/UrlUtils.php';
|
||||
|
||||
class CleanupUrlTest extends \PHPUnit\Framework\TestCase
|
||||
class CleanupUrlTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string reference URL
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Shaarli\Http;
|
|||
|
||||
require_once 'application/http/UrlUtils.php';
|
||||
|
||||
class GetUrlSchemeTest extends \PHPUnit\Framework\TestCase
|
||||
class GetUrlSchemeTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Get empty scheme string for empty UrlUtils
|
||||
|
|
|
@ -10,7 +10,7 @@ require_once 'application/http/UrlUtils.php';
|
|||
/**
|
||||
* Unitary tests for unparse_url()
|
||||
*/
|
||||
class UnparseUrlTest extends \PHPUnit\Framework\TestCase
|
||||
class UnparseUrlTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Thanks for building nothing
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once 'application/http/UrlUtils.php';
|
|||
*
|
||||
* 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).
|
||||
|
|
|
@ -12,7 +12,7 @@ use Shaarli\Config\ConfigManager;
|
|||
*
|
||||
* @package Shaarli
|
||||
*/
|
||||
class LanguagesFrTest extends \PHPUnit\Framework\TestCase
|
||||
class LanguagesFrTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Config file path (without extension).
|
||||
|
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shaarli\Legacy;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Front\Controller\Visitor\FrontControllerMockHelper;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ require_once 'tests/utils/ReferenceLinkDB.php';
|
|||
/**
|
||||
* Unitary tests for LegacyLinkDBTest
|
||||
*/
|
||||
class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
|
||||
class LegacyLinkDBTest extends \Shaarli\TestCase
|
||||
{
|
||||
// datastore to test write operations
|
||||
protected static $testDatastore = 'sandbox/datastore.php';
|
||||
|
@ -258,7 +258,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
|
|||
$link = self::$publicLinkDB->getLinkFromUrl('http://mediagoblin.org/');
|
||||
|
||||
$this->assertNotEquals(false, $link);
|
||||
$this->assertContains(
|
||||
$this->assertContainsPolyfill(
|
||||
'A free software media publishing platform',
|
||||
$link['description']
|
||||
);
|
||||
|
@ -471,9 +471,9 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$res = $linkDB->renameTag('cartoon', 'Taz');
|
||||
$this->assertEquals(3, count($res));
|
||||
$this->assertContains(' Taz ', $linkDB[4]['tags']);
|
||||
$this->assertContains(' Taz ', $linkDB[1]['tags']);
|
||||
$this->assertContains(' Taz ', $linkDB[0]['tags']);
|
||||
$this->assertContainsPolyfill(' Taz ', $linkDB[4]['tags']);
|
||||
$this->assertContainsPolyfill(' Taz ', $linkDB[1]['tags']);
|
||||
$this->assertContainsPolyfill(' Taz ', $linkDB[0]['tags']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,7 +513,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$res = $linkDB->renameTag('cartoon', null);
|
||||
$this->assertEquals(3, count($res));
|
||||
$this->assertNotContains('cartoon', $linkDB[4]['tags']);
|
||||
$this->assertNotContainsPolyfill('cartoon', $linkDB[4]['tags']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,7 @@ use Shaarli\Legacy\LegacyLinkFilter;
|
|||
/**
|
||||
* Class LegacyLinkFilterTest.
|
||||
*/
|
||||
class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
|
||||
class LegacyLinkFilterTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Test datastore path.
|
||||
|
|
|
@ -20,7 +20,7 @@ require_once 'inc/rain.tpl.class.php';
|
|||
* Class UpdaterTest.
|
||||
* Runs unit tests against the updater class.
|
||||
*/
|
||||
class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
|
||||
class LegacyUpdaterTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string Path to test datastore.
|
||||
|
@ -725,7 +725,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
|
|||
$this->assertEquals(\Shaarli\Thumbnailer::MODE_ALL, $this->conf->get('thumbnails.mode'));
|
||||
$this->assertEquals(125, $this->conf->get('thumbnails.width'));
|
||||
$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;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Formatter\BookmarkFormatter;
|
||||
use Shaarli\Formatter\FormatterFactory;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
require_once 'tests/utils/ReferenceLinkDB.php';
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
namespace Shaarli\Netscape;
|
||||
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Shaarli\Bookmark\Bookmark;
|
||||
use Shaarli\Bookmark\BookmarkFileService;
|
||||
use Shaarli\Bookmark\BookmarkFilter;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\History;
|
||||
use Shaarli\TestCase;
|
||||
use Slim\Http\UploadedFile;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,7 +9,7 @@ require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
|
|||
/**
|
||||
* Unit test for the Addlink toolbar plugin
|
||||
*/
|
||||
class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
|
||||
class PluginAddlinkTest extends \Shaarli\TestCase
|
||||
{
|
||||
/**
|
||||
* Reset plugin path.
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Shaarli\Plugin\Archiveorg;
|
|||
* PluginArchiveorgTest.php
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Plugin\PluginManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
require_once 'plugins/archiveorg/archiveorg.php';
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace Shaarli\Plugin\DefaultColors;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shaarli\Bookmark\LinkDB;
|
||||
use Shaarli\Config\ConfigManager;
|
||||
use Shaarli\Plugin\PluginManager;
|
||||
use Shaarli\TestCase;
|
||||
|
||||
require_once 'plugins/default_colors/default_colors.php';
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue