Comply with PHPUnit V8: setup/teardown functions must return void

This commit is contained in:
ArthurHoaro 2020-09-26 15:08:39 +02:00
parent 24225f6332
commit 8f60e1206e
47 changed files with 72 additions and 72 deletions

View file

@ -17,7 +17,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase
/**
* Reset test data for each test
*/
public function setUp()
protected function setUp(): void
{
FakeApplicationUtils::$VERSION_CODE = '';
if (file_exists(self::$testUpdateFile)) {
@ -28,7 +28,7 @@ class ApplicationUtilsTest extends \PHPUnit\Framework\TestCase
/**
* Remove test version file if it exists
*/
public function tearDown()
protected function tearDown(): void
{
if (is_file('sandbox/version.php')) {
unlink('sandbox/version.php');

View file

@ -19,7 +19,7 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase
/**
* Delete test file after every test.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$file);
}

View file

@ -16,7 +16,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
/**
* Delete history file.
*/
public function setUp()
protected function setUp(): void
{
if (file_exists(self::$historyFilePath)) {
unlink(self::$historyFilePath);

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
/**
* Assign reference data
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$defaultTimeZone = date_default_timezone_get();
// Timezone without DST for test consistency
@ -36,7 +36,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
/**
* Reset the timezone
*/
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
date_default_timezone_set(self::$defaultTimeZone);
}
@ -44,7 +44,7 @@ class UtilsTest extends PHPUnit\Framework\TestCase
/**
* Resets test data before each test
*/
protected function setUp()
protected function setUp(): void
{
if (file_exists(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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('api.secret', 'NapoleonWasALizard');
@ -61,7 +61,7 @@ class ApiMiddlewareTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
}

View file

@ -13,7 +13,7 @@ class ApiUtilsTest extends \PHPUnit\Framework\TestCase
/**
* Force the timezone for ISO datetimes.
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
date_default_timezone_set('UTC');
}

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refHistory = new \ReferenceHistory();
@ -57,7 +57,7 @@ class HistoryTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -67,7 +67,7 @@ class InfoTest extends TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -78,7 +78,7 @@ class DeleteLinkTest extends \PHPUnit\Framework\TestCase
/**
* After each test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
@unlink(self::$testHistory);

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -74,7 +74,7 @@ class GetLinkIdTest extends \PHPUnit\Framework\TestCase
/**
* After each test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
}

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -74,7 +74,7 @@ class GetLinksTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -107,7 +107,7 @@ class PostLinkTest extends TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
@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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -91,7 +91,7 @@ class PutLinkTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
@unlink(self::$testHistory);

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -79,7 +79,7 @@ class DeleteTagTest extends \PHPUnit\Framework\TestCase
/**
* After each test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
@unlink(self::$testHistory);

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -72,7 +72,7 @@ class GetTagNameTest extends \PHPUnit\Framework\TestCase
/**
* After each test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
}

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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -78,7 +78,7 @@ class GetTagsTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@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.
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
@ -84,7 +84,7 @@ class PutTagTest extends \PHPUnit\Framework\TestCase
/**
* After every test, remove the test datastore.
*/
public function tearDown()
protected function tearDown(): void
{
@unlink(self::$testDatastore);
@unlink(self::$testHistory);

View file

@ -66,7 +66,7 @@ class BookmarkFileServiceTest extends TestCase
*
* Resets test data for each test
*/
protected function setUp()
protected function setUp(): void
{
if (file_exists(self::$testDatastore)) {
unlink(self::$testDatastore);

View file

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

View file

@ -14,7 +14,7 @@ class ConfigManagerTest extends \PHPUnit\Framework\TestCase
*/
protected $conf;
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,7 +27,7 @@ class LanguagesFrTest extends \PHPUnit\Framework\TestCase
/**
* Init: force French
*/
public function setUp()
protected function setUp(): void
{
$this->conf = new ConfigManager(self::$configFile);
$this->conf->set('translation.language', 'fr');
@ -36,7 +36,7 @@ class LanguagesFrTest extends \PHPUnit\Framework\TestCase
/**
* 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'))) {
setlocale(LC_ALL, getenv('UT_LOCALE'));

View file

@ -52,7 +52,7 @@ class LegacyLinkDBTest extends \PHPUnit\Framework\TestCase
*
* Resets test data for each test
*/
protected function setUp()
protected function setUp(): void
{
if (file_exists(self::$testDatastore)) {
unlink(self::$testDatastore);

View file

@ -34,7 +34,7 @@ class LegacyLinkFilterTest extends \PHPUnit\Framework\TestCase
/**
* Instantiate linkFilter with ReferenceLinkDB data.
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$refDB = new ReferenceLinkDB(true);
self::$refDB->write(self::$testDatastore);

View file

@ -40,7 +40,7 @@ class LegacyUpdaterTest extends \PHPUnit\Framework\TestCase
/**
* Executed before each test.
*/
public function setUp()
protected function setUp(): void
{
copy('tests/utils/config/configJson.json.php', self::$configFile .'.json.php');
$this->conf = new ConfigManager(self::$configFile);
@ -754,7 +754,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
if (isset($_SESSION['warnings'])) {
unset($_SESSION['warnings']);
}
$updater = new LegacyUpdater([], [], $this->conf, true, $_SESSION);
$this->assertTrue($updater->updateMethodWebThumbnailer());
$this->assertFalse($this->conf->exists('thumbnail'));

View file

@ -54,7 +54,7 @@ class BookmarkExportTest extends TestCase
/**
* Instantiate reference data
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
static::$conf = new ConfigManager('tests/utils/config/configJson');
static::$conf->set('resource.datastore', static::$testDatastore);

View file

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

View file

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

View file

@ -19,7 +19,7 @@ class PluginDefaultColorsTest extends TestCase
/**
* Reset plugin path
*/
public function setUp()
protected function setUp(): void
{
PluginManager::$PLUGINS_PATH = 'sandbox';
mkdir(PluginManager::$PLUGINS_PATH . '/default_colors/');
@ -32,7 +32,7 @@ class PluginDefaultColorsTest extends TestCase
/**
* Remove sandbox files and folder
*/
public function tearDown()
protected function tearDown(): void
{
if (file_exists('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
*/
public function setUp()
protected function setUp(): void
{
PluginManager::$PLUGINS_PATH = 'plugins';
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -42,7 +42,7 @@ class UpdaterTest extends TestCase
/**
* Executed before each test.
*/
public function setUp()
protected function setUp(): void
{
$this->refDB = new \ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);