Merge pull request #1572 from ArthurHoaro/feature/php8

This commit is contained in:
ArthurHoaro 2020-09-29 11:36:27 +02:00 committed by GitHub
commit 6cdca9562c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 258 additions and 244 deletions

View file

@ -43,7 +43,8 @@ cache:
install: install:
# install/update composer and php dependencies # install/update composer and php dependencies
- composer install --prefer-dist - composer config --unset platform && composer config platform.php $TRAVIS_PHP_VERSION
- composer update
before_script: before_script:
- PATH=${PATH//:\.\/node_modules\/\.bin/} - PATH=${PATH//:\.\/node_modules\/\.bin/}

View file

@ -28,7 +28,7 @@
"require-dev": { "require-dev": {
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"phpunit/phpcov": "*", "phpunit/phpcov": "*",
"phpunit/phpunit": "^7.5", "phpunit/phpunit": "^7.5 || ^8.0",
"squizlabs/php_codesniffer": "3.*" "squizlabs/php_codesniffer": "3.*"
}, },
"suggest": { "suggest": {

View file

@ -17,7 +17,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset test data for each test * Reset test data for each test
*/ */
public function setUp() protected function setUp(): void
{ {
FakeApplicationUtils::$VERSION_CODE = ''; FakeApplicationUtils::$VERSION_CODE = '';
if (file_exists(self::$testUpdateFile)) { if (file_exists(self::$testUpdateFile)) {
@ -28,7 +28,7 @@ public function setUp()
/** /**
* Remove test version file if it exists * Remove test version file if it exists
*/ */
public function tearDown() protected function tearDown(): void
{ {
if (is_file('sandbox/version.php')) { if (is_file('sandbox/version.php')) {
unlink('sandbox/version.php'); unlink('sandbox/version.php');
@ -145,10 +145,11 @@ public function testCheckUpdateNewVersionUnavailable()
/** /**
* Test update checks - invalid Git branch * Test update checks - invalid Git branch
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid branch selected for updates/
*/ */
public function testCheckUpdateInvalidGitBranch() public function testCheckUpdateInvalidGitBranch()
{ {
$this->expectExceptionMessageRegExp('/Invalid branch selected for updates/');
ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable'); ApplicationUtils::checkUpdate('', 'null', 0, true, true, 'unstable');
} }
@ -261,20 +262,22 @@ public function testCheckSupportedPHPVersion()
/** /**
* Check a unsupported PHP version * Check a unsupported PHP version
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Your PHP version is obsolete/
*/ */
public function testCheckSupportedPHPVersion51() public function testCheckSupportedPHPVersion51()
{ {
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0')); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.1.0'));
} }
/** /**
* Check another unsupported PHP version * Check another unsupported PHP version
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Your PHP version is obsolete/
*/ */
public function testCheckSupportedPHPVersion52() public function testCheckSupportedPHPVersion52()
{ {
$this->expectExceptionMessageRegExp('/Your PHP version is obsolete/');
$this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2')); $this->assertTrue(ApplicationUtils::checkPHPVersion('5.3', '5.2'));
} }

View file

@ -19,7 +19,7 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase
/** /**
* Delete test file after every test. * Delete test file after every test.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$file); @unlink(self::$file);
} }
@ -49,12 +49,12 @@ public function testSimpleWriteRead()
/** /**
* File not writable: raise an exception. * File not writable: raise an exception.
*
* @expectedException Shaarli\Exceptions\IOException
* @expectedExceptionMessage Error accessing "sandbox/flat.db"
*/ */
public function testWriteWithoutPermission() public function testWriteWithoutPermission()
{ {
$this->expectException(\Shaarli\Exceptions\IOException::class);
$this->expectExceptionMessage('Error accessing "sandbox/flat.db"');
touch(self::$file); touch(self::$file);
chmod(self::$file, 0440); chmod(self::$file, 0440);
FileUtils::writeFlatDB(self::$file, null); FileUtils::writeFlatDB(self::$file, null);
@ -62,23 +62,23 @@ public function testWriteWithoutPermission()
/** /**
* Folder non existent: raise an exception. * Folder non existent: raise an exception.
*
* @expectedException Shaarli\Exceptions\IOException
* @expectedExceptionMessage Error accessing "nopefolder"
*/ */
public function testWriteFolderDoesNotExist() public function testWriteFolderDoesNotExist()
{ {
$this->expectException(\Shaarli\Exceptions\IOException::class);
$this->expectExceptionMessage('Error accessing "nopefolder"');
FileUtils::writeFlatDB('nopefolder/file', null); FileUtils::writeFlatDB('nopefolder/file', null);
} }
/** /**
* Folder non writable: raise an exception. * Folder non writable: raise an exception.
*
* @expectedException Shaarli\Exceptions\IOException
* @expectedExceptionMessage Error accessing "sandbox"
*/ */
public function testWriteFolderPermission() public function testWriteFolderPermission()
{ {
$this->expectException(\Shaarli\Exceptions\IOException::class);
$this->expectExceptionMessage('Error accessing "sandbox"');
chmod(dirname(self::$file), 0555); chmod(dirname(self::$file), 0555);
try { try {
FileUtils::writeFlatDB(self::$file, null); FileUtils::writeFlatDB(self::$file, null);

View file

@ -16,7 +16,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
/** /**
* Delete history file. * Delete history file.
*/ */
public function setUp() protected function setUp(): void
{ {
if (file_exists(self::$historyFilePath)) { if (file_exists(self::$historyFilePath)) {
unlink(self::$historyFilePath); unlink(self::$historyFilePath);
@ -44,12 +44,12 @@ public function testAddEventCreateFile()
/** /**
* Not writable history file: raise an exception. * Not writable history file: raise an exception.
*
* @expectedException Exception
* @expectedExceptionMessage History file isn't readable or writable
*/ */
public function testConstructNotWritable() public function testConstructNotWritable()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('History file isn\'t readable or writable');
touch(self::$historyFilePath); touch(self::$historyFilePath);
chmod(self::$historyFilePath, 0440); chmod(self::$historyFilePath, 0440);
$history = new History(self::$historyFilePath); $history = new History(self::$historyFilePath);
@ -58,12 +58,12 @@ public function testConstructNotWritable()
/** /**
* Not parsable history file: raise an exception. * Not parsable history file: raise an exception.
*
* @expectedException Exception
* @expectedExceptionMessageRegExp /Could not parse history file/
*/ */
public function testConstructNotParsable() public function testConstructNotParsable()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/Could not parse history file/');
file_put_contents(self::$historyFilePath, 'not parsable'); file_put_contents(self::$historyFilePath, 'not parsable');
$history = new History(self::$historyFilePath); $history = new History(self::$historyFilePath);
// gzinflate generates a warning // gzinflate generates a warning

View file

@ -22,7 +22,7 @@ class LanguagesTest extends \PHPUnit\Framework\TestCase
/** /**
* *
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager(self::$configFile); $this->conf = new ConfigManager(self::$configFile);
} }

View file

@ -30,7 +30,7 @@ class ThumbnailerTest extends TestCase
*/ */
protected $conf; protected $conf;
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('thumbnails.mode', Thumbnailer::MODE_ALL); $this->conf->set('thumbnails.mode', Thumbnailer::MODE_ALL);
@ -43,7 +43,7 @@ public function setUp()
WTConfigManager::addFile('tests/utils/config/wt.json'); WTConfigManager::addFile('tests/utils/config/wt.json');
} }
public function tearDown() protected function tearDown(): void
{ {
$this->rrmdirContent('sandbox/'); $this->rrmdirContent('sandbox/');
} }

View file

@ -15,7 +15,7 @@ class TimeZoneTest extends PHPUnit\Framework\TestCase
*/ */
protected $installedTimezones; protected $installedTimezones;
public function setUp() protected function setUp(): void
{ {
$this->installedTimezones = [ $this->installedTimezones = [
'Antarctica/Syowa', 'Antarctica/Syowa',

View file

@ -26,7 +26,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
/** /**
* Assign reference data * Assign reference data
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
self::$defaultTimeZone = date_default_timezone_get(); self::$defaultTimeZone = date_default_timezone_get();
// Timezone without DST for test consistency // Timezone without DST for test consistency
@ -36,7 +36,7 @@ public static function setUpBeforeClass()
/** /**
* Reset the timezone * Reset the timezone
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass(): void
{ {
date_default_timezone_set(self::$defaultTimeZone); date_default_timezone_set(self::$defaultTimeZone);
} }
@ -44,7 +44,7 @@ public static function tearDownAfterClass()
/** /**
* Resets test data before each test * Resets test data before each test
*/ */
protected function setUp() protected function setUp(): void
{ {
if (file_exists(self::$testLogFile)) { if (file_exists(self::$testLogFile)) {
unlink(self::$testLogFile); unlink(self::$testLogFile);

View file

@ -43,7 +43,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('api.secret', 'NapoleonWasALizard'); $this->conf->set('api.secret', 'NapoleonWasALizard');
@ -61,7 +61,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }

View file

@ -13,7 +13,7 @@ class ApiUtilsTest extends \PHPUnit\Framework\TestCase
/** /**
* Force the timezone for ISO datetimes. * Force the timezone for ISO datetimes.
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
} }
@ -66,143 +66,143 @@ public function testValidateJwtTokenValid()
/** /**
* Test validateJwtToken() with a malformed JWT token. * Test validateJwtToken() with a malformed JWT token.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Malformed JWT token
*/ */
public function testValidateJwtTokenMalformed() public function testValidateJwtTokenMalformed()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Malformed JWT token');
$token = 'ABC.DEF'; $token = 'ABC.DEF';
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with an empty JWT token. * Test validateJwtToken() with an empty JWT token.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Malformed JWT token
*/ */
public function testValidateJwtTokenMalformedEmpty() public function testValidateJwtTokenMalformedEmpty()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Malformed JWT token');
$token = false; $token = false;
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with a JWT token without header. * Test validateJwtToken() with a JWT token without header.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Malformed JWT token
*/ */
public function testValidateJwtTokenMalformedEmptyHeader() public function testValidateJwtTokenMalformedEmptyHeader()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Malformed JWT token');
$token = '.payload.signature'; $token = '.payload.signature';
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with a JWT token without payload * Test validateJwtToken() with a JWT token without payload
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Malformed JWT token
*/ */
public function testValidateJwtTokenMalformedEmptyPayload() public function testValidateJwtTokenMalformedEmptyPayload()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Malformed JWT token');
$token = 'header..signature'; $token = 'header..signature';
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with a JWT token with an empty signature. * Test validateJwtToken() with a JWT token with an empty signature.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT signature
*/ */
public function testValidateJwtTokenInvalidSignatureEmpty() public function testValidateJwtTokenInvalidSignatureEmpty()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT signature');
$token = 'header.payload.'; $token = 'header.payload.';
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with a JWT token with an invalid signature. * Test validateJwtToken() with a JWT token with an invalid signature.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT signature
*/ */
public function testValidateJwtTokenInvalidSignature() public function testValidateJwtTokenInvalidSignature()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT signature');
$token = 'header.payload.nope'; $token = 'header.payload.nope';
ApiUtils::validateJwtToken($token, 'foo'); ApiUtils::validateJwtToken($token, 'foo');
} }
/** /**
* Test validateJwtToken() with a JWT token with a signature generated with the wrong API secret. * Test validateJwtToken() with a JWT token with a signature generated with the wrong API secret.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT signature
*/ */
public function testValidateJwtTokenInvalidSignatureSecret() public function testValidateJwtTokenInvalidSignatureSecret()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT signature');
ApiUtils::validateJwtToken(self::generateValidJwtToken('foo'), 'bar'); ApiUtils::validateJwtToken(self::generateValidJwtToken('foo'), 'bar');
} }
/** /**
* Test validateJwtToken() with a JWT token with a an invalid header (not JSON). * Test validateJwtToken() with a JWT token with a an invalid header (not JSON).
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT header
*/ */
public function testValidateJwtTokenInvalidHeader() public function testValidateJwtTokenInvalidHeader()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT header');
$token = $this->generateCustomJwtToken('notJSON', '{"JSON":1}', 'secret'); $token = $this->generateCustomJwtToken('notJSON', '{"JSON":1}', 'secret');
ApiUtils::validateJwtToken($token, 'secret'); ApiUtils::validateJwtToken($token, 'secret');
} }
/** /**
* Test validateJwtToken() with a JWT token with a an invalid payload (not JSON). * Test validateJwtToken() with a JWT token with a an invalid payload (not JSON).
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT payload
*/ */
public function testValidateJwtTokenInvalidPayload() public function testValidateJwtTokenInvalidPayload()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT payload');
$token = $this->generateCustomJwtToken('{"JSON":1}', 'notJSON', 'secret'); $token = $this->generateCustomJwtToken('{"JSON":1}', 'notJSON', 'secret');
ApiUtils::validateJwtToken($token, 'secret'); ApiUtils::validateJwtToken($token, 'secret');
} }
/** /**
* Test validateJwtToken() with a JWT token without issued time. * Test validateJwtToken() with a JWT token without issued time.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT issued time
*/ */
public function testValidateJwtTokenInvalidTimeEmpty() public function testValidateJwtTokenInvalidTimeEmpty()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT issued time');
$token = $this->generateCustomJwtToken('{"JSON":1}', '{"JSON":1}', 'secret'); $token = $this->generateCustomJwtToken('{"JSON":1}', '{"JSON":1}', 'secret');
ApiUtils::validateJwtToken($token, 'secret'); ApiUtils::validateJwtToken($token, 'secret');
} }
/** /**
* Test validateJwtToken() with an expired JWT token. * Test validateJwtToken() with an expired JWT token.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT issued time
*/ */
public function testValidateJwtTokenInvalidTimeExpired() public function testValidateJwtTokenInvalidTimeExpired()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT issued time');
$token = $this->generateCustomJwtToken('{"JSON":1}', '{"iat":' . (time() - 600) . '}', 'secret'); $token = $this->generateCustomJwtToken('{"JSON":1}', '{"iat":' . (time() - 600) . '}', 'secret');
ApiUtils::validateJwtToken($token, 'secret'); ApiUtils::validateJwtToken($token, 'secret');
} }
/** /**
* Test validateJwtToken() with a JWT token issued in the future. * Test validateJwtToken() with a JWT token issued in the future.
*
* @expectedException \Shaarli\Api\Exceptions\ApiAuthorizationException
* @expectedExceptionMessage Invalid JWT issued time
*/ */
public function testValidateJwtTokenInvalidTimeFuture() public function testValidateJwtTokenInvalidTimeFuture()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiAuthorizationException::class);
$this->expectExceptionMessage('Invalid JWT issued time');
$token = $this->generateCustomJwtToken('{"JSON":1}', '{"iat":' . (time() + 60) . '}', 'secret'); $token = $this->generateCustomJwtToken('{"JSON":1}', '{"iat":' . (time() + 60) . '}', 'secret');
ApiUtils::validateJwtToken($token, 'secret'); ApiUtils::validateJwtToken($token, 'secret');
} }

View file

@ -41,7 +41,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refHistory = new \ReferenceHistory(); $this->refHistory = new \ReferenceHistory();
@ -57,7 +57,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testHistory); @unlink(self::$testHistory);
} }

View file

@ -47,7 +47,7 @@ class InfoTest extends TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -67,7 +67,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }

View file

@ -56,7 +56,7 @@ class DeleteLinkTest extends \PHPUnit\Framework\TestCase
/** /**
* Before each test, instantiate a new Api with its config, plugins and bookmarks. * Before each test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -78,7 +78,7 @@ public function setUp()
/** /**
* After each test, remove the test datastore. * After each test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
@unlink(self::$testHistory); @unlink(self::$testHistory);
@ -113,11 +113,11 @@ public function testDeleteLinkValid()
/** /**
* Test DELETE link endpoint: reach not existing ID. * Test DELETE link endpoint: reach not existing ID.
*
* @expectedException \Shaarli\Api\Exceptions\ApiLinkNotFoundException
*/ */
public function testDeleteLink404() public function testDeleteLink404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class);
$id = -1; $id = -1;
$this->assertFalse($this->bookmarkService->exists($id)); $this->assertFalse($this->bookmarkService->exists($id));
$env = Environment::mock([ $env = Environment::mock([

View file

@ -55,7 +55,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase
/** /**
* Before each test, instantiate a new Api with its config, plugins and bookmarks. * Before each test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -74,7 +74,7 @@ public function setUp()
/** /**
* After each test, remove the test datastore. * After each test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }
@ -120,12 +120,12 @@ public function testGetLinkId()
/** /**
* Test basic getLink service: get non existent link => ApiLinkNotFoundException. * Test basic getLink service: get non existent link => ApiLinkNotFoundException.
*
* @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException
* @expectedExceptionMessage Link not found
*/ */
public function testGetLink404() public function testGetLink404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class);
$this->expectExceptionMessage('Link not found');
$env = Environment::mock([ $env = Environment::mock([
'REQUEST_METHOD' => 'GET', 'REQUEST_METHOD' => 'GET',
]); ]);

View file

@ -55,7 +55,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -74,7 +74,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }

View file

@ -70,7 +70,7 @@ class PostLinkTest extends TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -107,7 +107,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
@unlink(self::$testHistory); @unlink(self::$testHistory);

View file

@ -62,7 +62,7 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -91,7 +91,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
@unlink(self::$testHistory); @unlink(self::$testHistory);
@ -218,12 +218,12 @@ public function testPutLinkDuplicate()
/** /**
* Test link update on non existent link => ApiLinkNotFoundException. * Test link update on non existent link => ApiLinkNotFoundException.
*
* @expectedException Shaarli\Api\Exceptions\ApiLinkNotFoundException
* @expectedExceptionMessage Link not found
*/ */
public function testGetLink404() public function testGetLink404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiLinkNotFoundException::class);
$this->expectExceptionMessage('Link not found');
$env = Environment::mock([ $env = Environment::mock([
'REQUEST_METHOD' => 'PUT', 'REQUEST_METHOD' => 'PUT',
]); ]);

View file

@ -57,7 +57,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase
/** /**
* Before each test, instantiate a new Api with its config, plugins and bookmarks. * Before each test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -79,7 +79,7 @@ public function setUp()
/** /**
* After each test, remove the test datastore. * After each test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
@unlink(self::$testHistory); @unlink(self::$testHistory);
@ -150,12 +150,12 @@ public function testDeleteTagCaseSensitivity()
/** /**
* Test DELETE tag endpoint: reach not existing tag. * Test DELETE tag endpoint: reach not existing tag.
*
* @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
* @expectedExceptionMessage Tag not found
*/ */
public function testDeleteLink404() public function testDeleteLink404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
$this->expectExceptionMessage('Tag not found');
$tagName = 'nopenope'; $tagName = 'nopenope';
$tags = $this->bookmarkService->bookmarksCountPerTag(); $tags = $this->bookmarkService->bookmarksCountPerTag();
$this->assertFalse(isset($tags[$tagName])); $this->assertFalse(isset($tags[$tagName]));

View file

@ -53,7 +53,7 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase
/** /**
* Before each test, instantiate a new Api with its config, plugins and bookmarks. * Before each test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -72,7 +72,7 @@ public function setUp()
/** /**
* After each test, remove the test datastore. * After each test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }
@ -117,12 +117,12 @@ public function testGetTagNotCaseSensitive()
/** /**
* Test basic getTag service: get non existent tag => ApiTagNotFoundException. * Test basic getTag service: get non existent tag => ApiTagNotFoundException.
*
* @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
* @expectedExceptionMessage Tag not found
*/ */
public function testGetTag404() public function testGetTag404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
$this->expectExceptionMessage('Tag not found');
$env = Environment::mock([ $env = Environment::mock([
'REQUEST_METHOD' => 'GET', 'REQUEST_METHOD' => 'GET',
]); ]);

View file

@ -57,7 +57,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -78,7 +78,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
} }

View file

@ -62,7 +62,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase
/** /**
* Before every test, instantiate a new Api with its config, plugins and bookmarks. * Before every test, instantiate a new Api with its config, plugins and bookmarks.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore); $this->conf->set('resource.datastore', self::$testDatastore);
@ -84,7 +84,7 @@ public function setUp()
/** /**
* After every test, remove the test datastore. * After every test, remove the test datastore.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$testDatastore); @unlink(self::$testDatastore);
@unlink(self::$testHistory); @unlink(self::$testHistory);
@ -159,12 +159,12 @@ public function testPutTagMerge()
/** /**
* Test tag update with an empty new tag name => ApiBadParametersException * Test tag update with an empty new tag name => ApiBadParametersException
*
* @expectedException Shaarli\Api\Exceptions\ApiBadParametersException
* @expectedExceptionMessage New tag name is required in the request body
*/ */
public function testPutTagEmpty() public function testPutTagEmpty()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiBadParametersException::class);
$this->expectExceptionMessage('New tag name is required in the request body');
$tagName = 'gnu'; $tagName = 'gnu';
$newName = ''; $newName = '';
@ -194,12 +194,12 @@ public function testPutTagEmpty()
/** /**
* Test tag update on non existent tag => ApiTagNotFoundException. * Test tag update on non existent tag => ApiTagNotFoundException.
*
* @expectedException Shaarli\Api\Exceptions\ApiTagNotFoundException
* @expectedExceptionMessage Tag not found
*/ */
public function testPutTag404() public function testPutTag404()
{ {
$this->expectException(\Shaarli\Api\Exceptions\ApiTagNotFoundException::class);
$this->expectExceptionMessage('Tag not found');
$env = Environment::mock([ $env = Environment::mock([
'REQUEST_METHOD' => 'PUT', 'REQUEST_METHOD' => 'PUT',
]); ]);

View file

@ -47,22 +47,22 @@ public function testArrayAccessAddEntries()
/** /**
* Test adding a bad entry: wrong type * Test adding a bad entry: wrong type
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryInstance() public function testArrayAccessAddBadEntryInstance()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$array[] = 'nope'; $array[] = 'nope';
} }
/** /**
* Test adding a bad entry: no id * Test adding a bad entry: no id
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryNoId() public function testArrayAccessAddBadEntryNoId()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$array[] = $bookmark; $array[] = $bookmark;
@ -70,11 +70,11 @@ public function testArrayAccessAddBadEntryNoId()
/** /**
* Test adding a bad entry: no url * Test adding a bad entry: no url
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryNoUrl() public function testArrayAccessAddBadEntryNoUrl()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$bookmark = (new Bookmark())->setId(11); $bookmark = (new Bookmark())->setId(11);
$array[] = $bookmark; $array[] = $bookmark;
@ -82,11 +82,11 @@ public function testArrayAccessAddBadEntryNoUrl()
/** /**
* Test adding a bad entry: invalid offset * Test adding a bad entry: invalid offset
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryOffset() public function testArrayAccessAddBadEntryOffset()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$bookmark = (new Bookmark())->setId(11); $bookmark = (new Bookmark())->setId(11);
$bookmark->validate(); $bookmark->validate();
@ -95,11 +95,11 @@ public function testArrayAccessAddBadEntryOffset()
/** /**
* Test adding a bad entry: invalid ID type * Test adding a bad entry: invalid ID type
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryIdType() public function testArrayAccessAddBadEntryIdType()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$bookmark = (new Bookmark())->setId('nope'); $bookmark = (new Bookmark())->setId('nope');
$bookmark->validate(); $bookmark->validate();
@ -108,11 +108,11 @@ public function testArrayAccessAddBadEntryIdType()
/** /**
* Test adding a bad entry: ID/offset not consistent * Test adding a bad entry: ID/offset not consistent
*
* @expectedException Shaarli\Bookmark\Exception\InvalidBookmarkException
*/ */
public function testArrayAccessAddBadEntryIdOffset() public function testArrayAccessAddBadEntryIdOffset()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\InvalidBookmarkException::class);
$array = new BookmarkArray(); $array = new BookmarkArray();
$bookmark = (new Bookmark())->setId(11); $bookmark = (new Bookmark())->setId(11);
$bookmark->validate(); $bookmark->validate();

View file

@ -66,7 +66,7 @@ class BookmarkFileServiceTest extends TestCase
* *
* Resets test data for each test * Resets test data for each test
*/ */
protected function setUp() protected function setUp(): void
{ {
if (file_exists(self::$testDatastore)) { if (file_exists(self::$testDatastore)) {
unlink(self::$testDatastore); unlink(self::$testDatastore);
@ -134,11 +134,11 @@ public function testGetDefinedNotSaved()
/** /**
* Test get() method for an undefined bookmark * Test get() method for an undefined bookmark
*
* @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testGetUndefined() public function testGetUndefined()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$this->privateLinkDB->get(666); $this->privateLinkDB->get(666);
} }
@ -230,13 +230,13 @@ public function testAddMinimal()
/** /**
* Test add() method for a bookmark without any field set and without writing the data store * Test add() method for a bookmark without any field set and without writing the data store
*
* @expectedExceptionMessage Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testAddMinimalNoWrite() public function testAddMinimalNoWrite()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$this->privateLinkDB->add($bookmark); $this->privateLinkDB->add($bookmark, false);
$bookmark = $this->privateLinkDB->get(43); $bookmark = $this->privateLinkDB->get(43);
$this->assertEquals(43, $bookmark->getId()); $this->assertEquals(43, $bookmark->getId());
@ -249,34 +249,34 @@ public function testAddMinimalNoWrite()
/** /**
* Test add() method while logged out * Test add() method while logged out
*
* @expectedException \Exception
* @expectedExceptionMessage You're not authorized to alter the datastore
*/ */
public function testAddLoggedOut() public function testAddLoggedOut()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('You\'re not authorized to alter the datastore');
$this->publicLinkDB->add(new Bookmark()); $this->publicLinkDB->add(new Bookmark());
} }
/** /**
* Test add() method with an entry which is not a bookmark instance * Test add() method with an entry which is not a bookmark instance
*
* @expectedException \Exception
* @expectedExceptionMessage Provided data is invalid
*/ */
public function testAddNotABookmark() public function testAddNotABookmark()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Provided data is invalid');
$this->privateLinkDB->add(['title' => 'hi!']); $this->privateLinkDB->add(['title' => 'hi!']);
} }
/** /**
* Test add() method with a Bookmark already containing an ID * Test add() method with a Bookmark already containing an ID
*
* @expectedException \Exception
* @expectedExceptionMessage This bookmarks already exists
*/ */
public function testAddWithId() public function testAddWithId()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('This bookmarks already exists');
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$bookmark->setId(43); $bookmark->setId(43);
$this->privateLinkDB->add($bookmark); $this->privateLinkDB->add($bookmark);
@ -397,44 +397,44 @@ public function testSetMinimalNoWrite()
/** /**
* Test set() method while logged out * Test set() method while logged out
*
* @expectedException \Exception
* @expectedExceptionMessage You're not authorized to alter the datastore
*/ */
public function testSetLoggedOut() public function testSetLoggedOut()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('You\'re not authorized to alter the datastore');
$this->publicLinkDB->set(new Bookmark()); $this->publicLinkDB->set(new Bookmark());
} }
/** /**
* Test set() method with an entry which is not a bookmark instance * Test set() method with an entry which is not a bookmark instance
*
* @expectedException \Exception
* @expectedExceptionMessage Provided data is invalid
*/ */
public function testSetNotABookmark() public function testSetNotABookmark()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Provided data is invalid');
$this->privateLinkDB->set(['title' => 'hi!']); $this->privateLinkDB->set(['title' => 'hi!']);
} }
/** /**
* Test set() method with a Bookmark without an ID defined. * Test set() method with a Bookmark without an ID defined.
*
* @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testSetWithoutId() public function testSetWithoutId()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$this->privateLinkDB->set($bookmark); $this->privateLinkDB->set($bookmark);
} }
/** /**
* Test set() method with a Bookmark with an unknow ID * Test set() method with a Bookmark with an unknow ID
*
* @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testSetWithUnknownId() public function testSetWithUnknownId()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$bookmark->setId(666); $bookmark->setId(666);
$this->privateLinkDB->set($bookmark); $this->privateLinkDB->set($bookmark);
@ -481,23 +481,23 @@ public function testAddOrSetExisting()
/** /**
* Test addOrSet() method while logged out * Test addOrSet() method while logged out
*
* @expectedException \Exception
* @expectedExceptionMessage You're not authorized to alter the datastore
*/ */
public function testAddOrSetLoggedOut() public function testAddOrSetLoggedOut()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('You\'re not authorized to alter the datastore');
$this->publicLinkDB->addOrSet(new Bookmark()); $this->publicLinkDB->addOrSet(new Bookmark());
} }
/** /**
* Test addOrSet() method with an entry which is not a bookmark instance * Test addOrSet() method with an entry which is not a bookmark instance
*
* @expectedException \Exception
* @expectedExceptionMessage Provided data is invalid
*/ */
public function testAddOrSetNotABookmark() public function testAddOrSetNotABookmark()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Provided data is invalid');
$this->privateLinkDB->addOrSet(['title' => 'hi!']); $this->privateLinkDB->addOrSet(['title' => 'hi!']);
} }
@ -524,11 +524,11 @@ public function testAddOrSetMinimalNoWrite()
/** /**
* Test remove() method with an existing Bookmark * Test remove() method with an existing Bookmark
*
* @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testRemoveExisting() public function testRemoveExisting()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$bookmark = $this->privateLinkDB->get(42); $bookmark = $this->privateLinkDB->get(42);
$this->privateLinkDB->remove($bookmark); $this->privateLinkDB->remove($bookmark);
@ -548,34 +548,34 @@ public function testRemoveExisting()
/** /**
* Test remove() method while logged out * Test remove() method while logged out
*
* @expectedException \Exception
* @expectedExceptionMessage You're not authorized to alter the datastore
*/ */
public function testRemoveLoggedOut() public function testRemoveLoggedOut()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('You\'re not authorized to alter the datastore');
$bookmark = $this->privateLinkDB->get(42); $bookmark = $this->privateLinkDB->get(42);
$this->publicLinkDB->remove($bookmark); $this->publicLinkDB->remove($bookmark);
} }
/** /**
* Test remove() method with an entry which is not a bookmark instance * Test remove() method with an entry which is not a bookmark instance
*
* @expectedException \Exception
* @expectedExceptionMessage Provided data is invalid
*/ */
public function testRemoveNotABookmark() public function testRemoveNotABookmark()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Provided data is invalid');
$this->privateLinkDB->remove(['title' => 'hi!']); $this->privateLinkDB->remove(['title' => 'hi!']);
} }
/** /**
* Test remove() method with a Bookmark with an unknown ID * Test remove() method with a Bookmark with an unknown ID
*
* @expectedException Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testRemoveWithUnknownId() public function testRemoveWithUnknownId()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$bookmark = new Bookmark(); $bookmark = new Bookmark();
$bookmark->setId(666); $bookmark->setId(666);
$this->privateLinkDB->remove($bookmark); $this->privateLinkDB->remove($bookmark);
@ -635,15 +635,15 @@ public function testInitialize()
* to make sure that nothing have been broken in the migration process. * to make sure that nothing have been broken in the migration process.
* They mostly cover search/filters. Some of them might be redundant with the previous ones. * They mostly cover search/filters. Some of them might be redundant with the previous ones.
*/ */
/** /**
* Attempt to instantiate a LinkDB whereas the datastore is not writable * Attempt to instantiate a LinkDB whereas the datastore is not writable
* *
* @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException * @expectedException Shaarli\Bookmark\Exception\NotWritableDataStoreException
* @expectedExceptionMessageRegExp #Couldn't load data from the data store file "null".*#
*/ */
public function testConstructDatastoreNotWriteable() public function testConstructDatastoreNotWriteable()
{ {
$this->expectExceptionMessageRegExp('#Couldn\'t load data from the data store file "null".*#');
$conf = new ConfigManager('tests/utils/config/configJson'); $conf = new ConfigManager('tests/utils/config/configJson');
$conf->set('resource.datastore', 'null/store.db'); $conf->set('resource.datastore', 'null/store.db');
new BookmarkFileService($conf, $this->history, true); new BookmarkFileService($conf, $this->history, true);

View file

@ -213,20 +213,22 @@ public function testFilterUnknownDay()
/** /**
* Use an invalid date format * Use an invalid date format
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid date format/
*/ */
public function testFilterInvalidDayWithChars() public function testFilterInvalidDayWithChars()
{ {
$this->expectExceptionMessageRegExp('/Invalid date format/');
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away'); self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, 'Rainy day, dream away');
} }
/** /**
* Use an invalid date format * Use an invalid date format
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid date format/
*/ */
public function testFilterInvalidDayDigits() public function testFilterInvalidDayDigits()
{ {
$this->expectExceptionMessageRegExp('/Invalid date format/');
self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20'); self::$linkFilter->filter(BookmarkFilter::$FILTER_DAY, '20');
} }
@ -250,11 +252,11 @@ public function testFilterSmallHash()
/** /**
* No link for this hash * No link for this hash
*
* @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testFilterUnknownSmallHash() public function testFilterUnknownSmallHash()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
self::$linkFilter->filter(BookmarkFilter::$FILTER_HASH, 'Iblaah'); self::$linkFilter->filter(BookmarkFilter::$FILTER_HASH, 'Iblaah');
} }

View file

@ -11,7 +11,7 @@ class ConfigJsonTest extends \PHPUnit\Framework\TestCase
*/ */
protected $configIO; protected $configIO;
public function setUp() protected function setUp(): void
{ {
$this->configIO = new ConfigJson(); $this->configIO = new ConfigJson();
} }
@ -38,12 +38,12 @@ public function testReadNonExistent()
/** /**
* Read a non existent config file -> empty array. * Read a non existent config file -> empty array.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp /An error occurred while parsing JSON configuration file \([\w\/\.]+\): error code #4/
*/ */
public function testReadInvalidJson() public function testReadInvalidJson()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp(' /An error occurred while parsing JSON configuration file \\([\\w\\/\\.]+\\): error code #4/');
$this->configIO->read('tests/utils/config/configInvalid.json.php'); $this->configIO->read('tests/utils/config/configInvalid.json.php');
} }
@ -110,22 +110,22 @@ public function testOverwrite()
/** /**
* Write to invalid path. * Write to invalid path.
*
* @expectedException \Shaarli\Exceptions\IOException
*/ */
public function testWriteInvalidArray() public function testWriteInvalidArray()
{ {
$this->expectException(\Shaarli\Exceptions\IOException::class);
$conf = array('conf' => 'value'); $conf = array('conf' => 'value');
@$this->configIO->write(array(), $conf); @$this->configIO->write(array(), $conf);
} }
/** /**
* Write to invalid path. * Write to invalid path.
*
* @expectedException \Shaarli\Exceptions\IOException
*/ */
public function testWriteInvalidBlank() public function testWriteInvalidBlank()
{ {
$this->expectException(\Shaarli\Exceptions\IOException::class);
$conf = array('conf' => 'value'); $conf = array('conf' => 'value');
@$this->configIO->write('', $conf); @$this->configIO->write('', $conf);
} }

View file

@ -14,7 +14,7 @@ class ConfigManagerTest extends \PHPUnit\Framework\TestCase
*/ */
protected $conf; protected $conf;
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager('tests/utils/config/configJson'); $this->conf = new ConfigManager('tests/utils/config/configJson');
} }
@ -95,44 +95,44 @@ public function testSetDeleteNested()
/** /**
* Set with an empty key. * Set with an empty key.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/ */
public function testSetEmptyKey() public function testSetEmptyKey()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
$this->conf->set('', 'stuff'); $this->conf->set('', 'stuff');
} }
/** /**
* Set with an array key. * Set with an array key.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/ */
public function testSetArrayKey() public function testSetArrayKey()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
$this->conf->set(array('foo' => 'bar'), 'stuff'); $this->conf->set(array('foo' => 'bar'), 'stuff');
} }
/** /**
* Remove with an empty key. * Remove with an empty key.
*
* @expectedException \Exception
* @expectedExceptionMessageRegExp #^Invalid setting key parameter. String expected, got.*#
*/ */
public function testRmoveEmptyKey() public function testRmoveEmptyKey()
{ {
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('#^Invalid setting key parameter. String expected, got.*#');
$this->conf->remove(''); $this->conf->remove('');
} }
/** /**
* Try to write the config without mandatory parameter (e.g. 'login'). * Try to write the config without mandatory parameter (e.g. 'login').
*
* @expectedException Shaarli\Config\Exception\MissingFieldConfigException
*/ */
public function testWriteMissingParameter() public function testWriteMissingParameter()
{ {
$this->expectException(\Shaarli\Config\Exception\MissingFieldConfigException::class);
$this->conf->setConfigFile('tests/utils/config/configTmp'); $this->conf->setConfigFile('tests/utils/config/configTmp');
$this->assertFalse(file_exists($this->conf->getConfigFileExt())); $this->assertFalse(file_exists($this->conf->getConfigFileExt()));
$this->conf->reload(); $this->conf->reload();

View file

@ -15,7 +15,7 @@ class ConfigPhpTest extends \PHPUnit\Framework\TestCase
*/ */
protected $configIO; protected $configIO;
public function setUp() protected function setUp(): void
{ {
$this->configIO = new ConfigPhp(); $this->configIO = new ConfigPhp();
} }

View file

@ -46,11 +46,11 @@ public function testSavePluginConfigValid()
/** /**
* Test save_plugin_config with invalid data. * Test save_plugin_config with invalid data.
*
* @expectedException Shaarli\Config\Exception\PluginConfigOrderException
*/ */
public function testSavePluginConfigInvalid() public function testSavePluginConfigInvalid()
{ {
$this->expectException(\Shaarli\Config\Exception\PluginConfigOrderException::class);
$data = array( $data = array(
'plugin2' => 0, 'plugin2' => 0,
'plugin3' => 0, 'plugin3' => 0,

View file

@ -17,7 +17,7 @@ class CachedPageTest extends \PHPUnit\Framework\TestCase
/** /**
* Create the cache directory if needed * Create the cache directory if needed
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
if (!is_dir(self::$testCacheDir)) { if (!is_dir(self::$testCacheDir)) {
mkdir(self::$testCacheDir); mkdir(self::$testCacheDir);
@ -28,7 +28,7 @@ public static function setUpBeforeClass()
/** /**
* Reset the page cache * Reset the page cache
*/ */
public function setUp() protected function setUp(): void
{ {
if (file_exists(self::$filename)) { if (file_exists(self::$filename)) {
unlink(self::$filename); unlink(self::$filename);

View file

@ -25,7 +25,7 @@ class BookmarkDefaultFormatterTest extends TestCase
/** /**
* Initialize formatter instance. * Initialize formatter instance.
*/ */
public function setUp() protected function setUp(): void
{ {
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf); $this->conf = new ConfigManager(self::$testConf);

View file

@ -25,7 +25,7 @@ class BookmarkMarkdownFormatterTest extends TestCase
/** /**
* Initialize formatter instance. * Initialize formatter instance.
*/ */
public function setUp() protected function setUp(): void
{ {
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf); $this->conf = new ConfigManager(self::$testConf);

View file

@ -25,7 +25,7 @@ class BookmarkRawFormatterTest extends TestCase
/** /**
* Initialize formatter instance. * Initialize formatter instance.
*/ */
public function setUp() protected function setUp(): void
{ {
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf); $this->conf = new ConfigManager(self::$testConf);

View file

@ -24,7 +24,7 @@ class FormatterFactoryTest extends TestCase
/** /**
* Initialize FormatterFactory instance * Initialize FormatterFactory instance
*/ */
public function setUp() protected function setUp(): void
{ {
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php'); copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf); $this->conf = new ConfigManager(self::$testConf);

View file

@ -27,7 +27,7 @@ class LanguagesFrTest extends \PHPUnit\Framework\TestCase
/** /**
* Init: force French * Init: force French
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new ConfigManager(self::$configFile); $this->conf = new ConfigManager(self::$configFile);
$this->conf->set('translation.language', 'fr'); $this->conf->set('translation.language', 'fr');
@ -36,7 +36,7 @@ public function setUp()
/** /**
* Reset the locale since gettext seems to mess with it, making it too long * Reset the locale since gettext seems to mess with it, making it too long
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass(): void
{ {
if (! empty(getenv('UT_LOCALE'))) { if (! empty(getenv('UT_LOCALE'))) {
setlocale(LC_ALL, getenv('UT_LOCALE')); setlocale(LC_ALL, getenv('UT_LOCALE'));

View file

@ -52,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
* *
* Resets test data for each test * Resets test data for each test
*/ */
protected function setUp() protected function setUp(): void
{ {
if (file_exists(self::$testDatastore)) { if (file_exists(self::$testDatastore)) {
unlink(self::$testDatastore); unlink(self::$testDatastore);
@ -101,10 +101,11 @@ public function testConstructLoggedOut()
* Attempt to instantiate a LinkDB whereas the datastore is not writable * Attempt to instantiate a LinkDB whereas the datastore is not writable
* *
* @expectedException Shaarli\Exceptions\IOException * @expectedException Shaarli\Exceptions\IOException
* @expectedExceptionMessageRegExp /Error accessing "null"/
*/ */
public function testConstructDatastoreNotWriteable() public function testConstructDatastoreNotWriteable()
{ {
$this->expectExceptionMessageRegExp('/Error accessing "null"/');
new LegacyLinkDB('null/store.db', false, false); new LegacyLinkDB('null/store.db', false, false);
} }
@ -420,22 +421,22 @@ public function testFilterHashValid()
/** /**
* Test filterHash() with an invalid smallhash. * Test filterHash() with an invalid smallhash.
*
* @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testFilterHashInValid1() public function testFilterHashInValid1()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
$request = 'blabla'; $request = 'blabla';
self::$publicLinkDB->filterHash($request); self::$publicLinkDB->filterHash($request);
} }
/** /**
* Test filterHash() with an empty smallhash. * Test filterHash() with an empty smallhash.
*
* @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testFilterHashInValid() public function testFilterHashInValid()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
self::$publicLinkDB->filterHash(''); self::$publicLinkDB->filterHash('');
} }

View file

@ -34,7 +34,7 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
/** /**
* Instantiate linkFilter with ReferenceLinkDB data. * Instantiate linkFilter with ReferenceLinkDB data.
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
self::$refDB = new ReferenceLinkDB(true); self::$refDB = new ReferenceLinkDB(true);
self::$refDB->write(self::$testDatastore); self::$refDB->write(self::$testDatastore);
@ -198,20 +198,22 @@ public function testFilterUnknownDay()
/** /**
* Use an invalid date format * Use an invalid date format
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid date format/
*/ */
public function testFilterInvalidDayWithChars() public function testFilterInvalidDayWithChars()
{ {
$this->expectExceptionMessageRegExp('/Invalid date format/');
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away'); self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, 'Rainy day, dream away');
} }
/** /**
* Use an invalid date format * Use an invalid date format
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid date format/
*/ */
public function testFilterInvalidDayDigits() public function testFilterInvalidDayDigits()
{ {
$this->expectExceptionMessageRegExp('/Invalid date format/');
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20'); self::$linkFilter->filter(LegacyLinkFilter::$FILTER_DAY, '20');
} }
@ -235,11 +237,11 @@ public function testFilterSmallHash()
/** /**
* No link for this hash * No link for this hash
*
* @expectedException \Shaarli\Bookmark\Exception\BookmarkNotFoundException
*/ */
public function testFilterUnknownSmallHash() public function testFilterUnknownSmallHash()
{ {
$this->expectException(\Shaarli\Bookmark\Exception\BookmarkNotFoundException::class);
self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah'); self::$linkFilter->filter(LegacyLinkFilter::$FILTER_HASH, 'Iblaah');
} }

View file

@ -40,7 +40,7 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
/** /**
* Executed before each test. * Executed before each test.
*/ */
public function setUp() protected function setUp(): void
{ {
copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php'); copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
$this->conf = new ConfigManager(self::$configFile); $this->conf = new ConfigManager(self::$configFile);
@ -82,10 +82,11 @@ public function testReadWriteUpdatesFile()
* Test errors in UpdaterUtils::write_updates_file(): empty updates file. * Test errors in UpdaterUtils::write_updates_file(): empty updates file.
* *
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
*/ */
public function testWriteEmptyUpdatesFile() public function testWriteEmptyUpdatesFile()
{ {
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
UpdaterUtils::write_updates_file('', array('test')); UpdaterUtils::write_updates_file('', array('test'));
} }
@ -93,10 +94,11 @@ public function testWriteEmptyUpdatesFile()
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file. * Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
* *
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Unable to write(.*)/
*/ */
public function testWriteUpdatesFileNotWritable() public function testWriteUpdatesFileNotWritable()
{ {
$this->expectExceptionMessageRegExp('/Unable to write(.*)/');
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile); touch($updatesFile);
chmod($updatesFile, 0444); chmod($updatesFile, 0444);
@ -161,11 +163,11 @@ public function testOneUpdate()
/** /**
* Test Update failed. * Test Update failed.
*
* @expectedException \Exception
*/ */
public function testUpdateFailed() public function testUpdateFailed()
{ {
$this->expectException(\Exception::class);
$updates = array( $updates = array(
'updateMethodDummy1', 'updateMethodDummy1',
'updateMethodDummy2', 'updateMethodDummy2',
@ -754,7 +756,7 @@ public function testUpdateMethodWebThumbnailerNothingToDo()
if (isset($_SESSION['warnings'])) { if (isset($_SESSION['warnings'])) {
unset($_SESSION['warnings']); unset($_SESSION['warnings']);
} }
$updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION); $updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION);
$this->assertTrue($updater->updateMethodWebThumbnailer()); $this->assertTrue($updater->updateMethodWebThumbnailer());
$this->assertFalse($this->conf->exists('thumbnail')); $this->assertFalse($this->conf->exists('thumbnail'));

View file

@ -54,7 +54,7 @@ class BookmarkExportTest extends TestCase
/** /**
* Instantiate reference data * Instantiate reference data
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
static::$conf = new ConfigManager('tests/utils/config/configJson'); static::$conf = new ConfigManager('tests/utils/config/configJson');
static::$conf->set('resource.datastore', static::$testDatastore); static::$conf->set('resource.datastore', static::$testDatastore);
@ -78,10 +78,11 @@ public function setUp(): void
/** /**
* Attempt to export an invalid link selection * Attempt to export an invalid link selection
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Invalid export selection/
*/ */
public function testFilterAndFormatInvalid() public function testFilterAndFormatInvalid()
{ {
$this->expectExceptionMessageRegExp('/Invalid export selection/');
$this->netscapeBookmarkUtils->filterAndFormat( $this->netscapeBookmarkUtils->filterAndFormat(
self::$formatter, self::$formatter,
'derp', 'derp',

View file

@ -75,7 +75,7 @@ class BookmarkImportTest extends TestCase
*/ */
protected static $defaultTimeZone; protected static $defaultTimeZone;
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
self::$defaultTimeZone = date_default_timezone_get(); self::$defaultTimeZone = date_default_timezone_get();
// Timezone without DST for test consistency // Timezone without DST for test consistency
@ -85,7 +85,7 @@ public static function setUpBeforeClass()
/** /**
* Resets test data before each test * Resets test data before each test
*/ */
protected function setUp() protected function setUp(): void
{ {
if (file_exists(self::$testDatastore)) { if (file_exists(self::$testDatastore)) {
unlink(self::$testDatastore); unlink(self::$testDatastore);
@ -104,12 +104,12 @@ protected function setUp()
/** /**
* Delete history file. * Delete history file.
*/ */
public function tearDown() protected function tearDown(): void
{ {
@unlink(self::$historyFilePath); @unlink(self::$historyFilePath);
} }
public static function tearDownAfterClass() public static function tearDownAfterClass(): void
{ {
date_default_timezone_set(self::$defaultTimeZone); date_default_timezone_set(self::$defaultTimeZone);
} }

View file

@ -14,7 +14,7 @@ class PluginAddlinkTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path. * Reset plugin path.
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'plugins'; PluginManager::$PLUGINS_PATH = 'plugins';
} }

View file

@ -19,7 +19,7 @@ class PluginDefaultColorsTest extends TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'sandbox'; PluginManager::$PLUGINS_PATH = 'sandbox';
mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/'); mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/');
@ -32,7 +32,7 @@ public function setUp()
/** /**
* Remove sandbox files and folder * Remove sandbox files and folder
*/ */
public function tearDown() protected function tearDown(): void
{ {
if (file_exists('sandbox/default_colors/default_colors.css.template')) { if (file_exists('sandbox/default_colors/default_colors.css.template')) {
unlink('sandbox/default_colors/default_colors.css.template'); unlink('sandbox/default_colors/default_colors.css.template');

View file

@ -19,7 +19,7 @@ class PluginPlayvideosTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'plugins'; PluginManager::$PLUGINS_PATH = 'plugins';
} }

View file

@ -21,7 +21,7 @@ class PluginPubsubhubbubTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'plugins'; PluginManager::$PLUGINS_PATH = 'plugins';
} }

View file

@ -19,7 +19,7 @@ class PluginQrcodeTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'plugins'; PluginManager::$PLUGINS_PATH = 'plugins';
} }

View file

@ -15,7 +15,7 @@ class PluginWallabagTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
PluginManager::$PLUGINS_PATH = 'plugins'; PluginManager::$PLUGINS_PATH = 'plugins';
} }

View file

@ -14,7 +14,7 @@ class WallabagInstanceTest extends \PHPUnit\Framework\TestCase
/** /**
* Reset plugin path * Reset plugin path
*/ */
public function setUp() protected function setUp(): void
{ {
$this->instance = 'http://some.url'; $this->instance = 'http://some.url';
} }

View file

@ -29,7 +29,7 @@ class PageCacheManagerTest extends TestCase
/** /**
* Populate the cache with dummy files * Populate the cache with dummy files
*/ */
public function setUp() protected function setUp(): void
{ {
$this->cacheManager = new PageCacheManager(static::$testCacheDir, true); $this->cacheManager = new PageCacheManager(static::$testCacheDir, true);
@ -48,7 +48,7 @@ public function setUp()
/** /**
* Remove dummycache folder after each tests. * Remove dummycache folder after each tests.
*/ */
public function tearDown() protected function tearDown(): void
{ {
array_map('unlink', glob(self::$testCacheDir . '/*')); array_map('unlink', glob(self::$testCacheDir . '/*'));
rmdir(self::$testCacheDir); rmdir(self::$testCacheDir);

View file

@ -32,7 +32,7 @@ class BanManagerTest extends TestCase
/** /**
* Prepare or reset test resources * Prepare or reset test resources
*/ */
public function setUp() protected function setUp(): void
{ {
if (file_exists($this->banFile)) { if (file_exists($this->banFile)) {
unlink($this->banFile); unlink($this->banFile);

View file

@ -63,7 +63,7 @@ class LoginManagerTest extends TestCase
/** /**
* Prepare or reset test resources * Prepare or reset test resources
*/ */
public function setUp() protected function setUp(): void
{ {
if (file_exists($this->banFile)) { if (file_exists($this->banFile)) {
unlink($this->banFile); unlink($this->banFile);

View file

@ -24,7 +24,7 @@ class SessionManagerTest extends TestCase
/** /**
* Assign reference data * Assign reference data
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
self::$sidHashes = \ReferenceSessionIdHashes::getHashes(); self::$sidHashes = \ReferenceSessionIdHashes::getHashes();
} }
@ -32,7 +32,7 @@ public static function setUpBeforeClass()
/** /**
* Initialize or reset test resources * Initialize or reset test resources
*/ */
public function setUp() protected function setUp(): void
{ {
$this->conf = new \FakeConfigManager([ $this->conf = new \FakeConfigManager([
'credentials.login' => 'johndoe', 'credentials.login' => 'johndoe',

View file

@ -42,7 +42,7 @@ class UpdaterTest extends TestCase
/** /**
* Executed before each test. * Executed before each test.
*/ */
public function setUp() protected function setUp(): void
{ {
$this->refDB = new \ReferenceLinkDB(); $this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore); $this->refDB->write(self::$testDatastore);
@ -89,10 +89,11 @@ public function testReadWriteUpdatesFile()
* Test errors in UpdaterUtils::write_updates_file(): empty updates file. * Test errors in UpdaterUtils::write_updates_file(): empty updates file.
* *
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Updates file path is not set(.*)/
*/ */
public function testWriteEmptyUpdatesFile() public function testWriteEmptyUpdatesFile()
{ {
$this->expectExceptionMessageRegExp('/Updates file path is not set(.*)/');
UpdaterUtils::write_updates_file('', array('test')); UpdaterUtils::write_updates_file('', array('test'));
} }
@ -100,10 +101,11 @@ public function testWriteEmptyUpdatesFile()
* Test errors in UpdaterUtils::write_updates_file(): not writable updates file. * Test errors in UpdaterUtils::write_updates_file(): not writable updates file.
* *
* @expectedException Exception * @expectedException Exception
* @expectedExceptionMessageRegExp /Unable to write(.*)/
*/ */
public function testWriteUpdatesFileNotWritable() public function testWriteUpdatesFileNotWritable()
{ {
$this->expectExceptionMessageRegExp('/Unable to write(.*)/');
$updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
touch($updatesFile); touch($updatesFile);
chmod($updatesFile, 0444); chmod($updatesFile, 0444);
@ -168,11 +170,11 @@ public function testOneUpdate()
/** /**
* Test Update failed. * Test Update failed.
*
* @expectedException \Exception
*/ */
public function testUpdateFailed() public function testUpdateFailed()
{ {
$this->expectException(\Exception::class);
$updates = array( $updates = array(
'updateMethodDummy1', 'updateMethodDummy1',
'updateMethodDummy2', 'updateMethodDummy2',