Compatibility with PHPUnit 9

This commit is contained in:
ArthurHoaro 2020-09-29 14:41:40 +02:00
parent 2b7a7bc928
commit a5a9cf23ac
112 changed files with 351 additions and 253 deletions

View file

@ -5,6 +5,9 @@ matrix:
# jobs for each supported php version # jobs for each supported php version
- language: php - language: php
php: nightly # PHP 8.0 php: nightly # PHP 8.0
install:
- composer self-update --2
- composer update --ignore-platform-req=php
- language: php - language: php
php: 7.4 php: 7.4
- language: php - language: php
@ -45,7 +48,6 @@ cache:
install: install:
# install/update composer and php dependencies # 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 config --unset platform && composer config platform.php $TRAVIS_PHP_VERSION
- composer update - composer update

View 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 || ^9.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",

View file

@ -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';

View file

@ -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.

View file

@ -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

View file

@ -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).

View file

@ -6,7 +6,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.

77
tests/TestCase.php Normal file
View 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;
}
}

View file

@ -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;

View file

@ -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

View file

@ -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';

View file

@ -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;
@ -109,7 +109,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);
} }
/** /**
@ -132,7 +132,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);
} }
/** /**
@ -157,7 +157,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);
} }
/** /**
@ -180,7 +180,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);
} }
/** /**
@ -206,6 +206,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);
} }
} }

View file

@ -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.

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
@ -748,7 +748,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()
); );

View file

@ -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.

View file

@ -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

View file

@ -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());
} }
/** /**

View file

@ -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';
@ -437,13 +437,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);
} }
/** /**
@ -454,9 +454,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);
} }
/** /**

View file

@ -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';

View file

@ -4,7 +4,7 @@
/** /**
* Class ConfigJsonTest * Class ConfigJsonTest
*/ */
class ConfigJsonTest extends \PHPUnit\Framework\TestCase class ConfigJsonTest extends \Shaarli\TestCase
{ {
/** /**
* @var ConfigJson * @var ConfigJson

View file

@ -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

View file

@ -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

View file

@ -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.

View file

@ -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;

View file

@ -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';

View file

@ -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']);
} }
} }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
}) })

View file

@ -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;

View file

@ -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;

View file

@ -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;
}) })

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
/** /**

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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,11 +78,11 @@ 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::assertArrayHasKey('linksToDisplay', $data);
static::assertCount(3, $data['linksToDisplay']); static::assertCount(3, $data['linksToDisplay']);
static::assertSame(1, $data['linksToDisplay'][0]['id']); static::assertSame(1, $data['linksToDisplay'][0]['id']);
@ -91,6 +91,7 @@ public function testValidIndexControllerInvokeDefault(): void
static::assertSame('20200516', $data['nextday']); static::assertSame('20200516', $data['nextday']);
static::assertArrayHasKey('loggedin', $param); static::assertArrayHasKey('loggedin', $param);
}
return $data; return $data;
}) })
@ -203,11 +204,11 @@ 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::assertArrayHasKey('linksToDisplay', $data);
static::assertCount(1, $data['linksToDisplay']); static::assertCount(1, $data['linksToDisplay']);
static::assertSame(1, $data['linksToDisplay'][0]['id']); static::assertSame(1, $data['linksToDisplay'][0]['id']);
@ -216,6 +217,7 @@ public function testValidIndexControllerInvokeNoFutureOrPast(): void
static::assertEmpty($data['nextday']); static::assertEmpty($data['nextday']);
static::assertArrayHasKey('loggedin', $param); 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;

View file

@ -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;

View file

@ -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;

View file

@ -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']);
}
}) })
; ;

View file

@ -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;
} }

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;
}); });

View file

@ -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;

View file

@ -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;

View file

@ -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;
}) })

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -7,7 +7,7 @@
/** /**
* Unitary tests for getIpAddressFromProxy() * Unitary tests for getIpAddressFromProxy()
*/ */
class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase class GetIpAdressFromProxyTest extends \Shaarli\TestCase
{ {
/** /**

View file

@ -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';

View file

@ -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.

View file

@ -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
{ {
/** /**

View file

@ -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

View file

@ -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

View file

@ -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';

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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).

View file

@ -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).

View file

@ -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;

View file

@ -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';
@ -258,7 +258,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 +471,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 +513,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']);
} }
/** /**

View file

@ -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.

View file

@ -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.
@ -725,7 +725,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]);
} }
/** /**

View file

@ -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';

View file

@ -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;
/** /**

View file

@ -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.

View file

@ -6,8 +6,8 @@
* PluginArchiveorgTest.php * PluginArchiveorgTest.php
*/ */
use PHPUnit\Framework\TestCase;
use Shaarli\Plugin\PluginManager; use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
require_once 'plugins/archiveorg/archiveorg.php'; require_once 'plugins/archiveorg/archiveorg.php';

View file

@ -2,10 +2,10 @@
namespace Shaarli\Plugin\DefaultColors; namespace Shaarli\Plugin\DefaultColors;
use PHPUnit\Framework\TestCase;
use Shaarli\Bookmark\LinkDB; use Shaarli\Bookmark\LinkDB;
use Shaarli\Config\ConfigManager; use Shaarli\Config\ConfigManager;
use Shaarli\Plugin\PluginManager; use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
require_once 'plugins/default_colors/default_colors.php'; require_once 'plugins/default_colors/default_colors.php';

Some files were not shown because too many files have changed in this diff Show more