diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index b69adc4a1e..cc13c4bc89 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -27,4 +27,18 @@ namespace Friendica\Test; abstract class DatabaseTest extends MockedTest { use DatabaseTestTrait; + + protected function setUp(): void + { + $this->setUpDb(); + + parent::setUp(); + } + + protected function tearDown(): void + { + $this->tearDownDb(); + + parent::tearDown(); + } } diff --git a/tests/DatabaseTestTrait.php b/tests/DatabaseTestTrait.php index f667e05de6..7d255c693b 100644 --- a/tests/DatabaseTestTrait.php +++ b/tests/DatabaseTestTrait.php @@ -29,23 +29,23 @@ use Friendica\Test\Util\Database\StaticDatabase; */ trait DatabaseTestTrait { - protected function setUp() + protected function setUpDb() { StaticDatabase::statConnect($_SERVER); // Rollbacks every DB usage (in case the test couldn't call tearDown) StaticDatabase::statRollback(); // Start the first, outer transaction StaticDatabase::getGlobConnection()->beginTransaction(); - - parent::setUp(); } - protected function tearDown() + protected function tearDownDb() { - // Rollbacks every DB usage so we don't commit anything into the DB - StaticDatabase::statRollback(); - - parent::tearDown(); + try { + // Rollbacks every DB usage so we don't commit anything into the DB + StaticDatabase::statRollback(); + } catch (\PDOException $exception) { + print_r("Found already rolled back transaction"); + } } /** diff --git a/tests/FixtureTest.php b/tests/FixtureTest.php index 74abfdddbd..f30b50878b 100644 --- a/tests/FixtureTest.php +++ b/tests/FixtureTest.php @@ -26,7 +26,7 @@ abstract class FixtureTest extends DatabaseTest /** * Create variables used by tests. */ - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/MockedTest.php b/tests/MockedTest.php index 81e43d669a..fdbfe219dd 100644 --- a/tests/MockedTest.php +++ b/tests/MockedTest.php @@ -28,7 +28,7 @@ use PHPUnit\Framework\TestCase; */ abstract class MockedTest extends TestCase { - protected function tearDown() + protected function tearDown() : void { \Mockery::close(); diff --git a/tests/Util/Database/ExtendedPDO.php b/tests/Util/Database/ExtendedPDO.php index 606d91d0ec..6a59d2aeec 100644 --- a/tests/Util/Database/ExtendedPDO.php +++ b/tests/Util/Database/ExtendedPDO.php @@ -67,8 +67,9 @@ class ExtendedPDO extends PDO */ public function beginTransaction() { - if($this->_transactionDepth == 0 || !$this->hasSavepoint()) { + if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) { parent::beginTransaction(); + $this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth; } else { $this->exec("SAVEPOINT LEVEL{$this->_transactionDepth}"); } @@ -85,8 +86,9 @@ class ExtendedPDO extends PDO { $this->_transactionDepth--; - if($this->_transactionDepth == 0 || !$this->hasSavepoint()) { + if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) { parent::commit(); + $this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth; } else { $this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}"); } @@ -100,8 +102,7 @@ class ExtendedPDO extends PDO */ public function rollBack() { - - if ($this->_transactionDepth == 0) { + if ($this->_transactionDepth <= 0) { throw new PDOException('Rollback error : There is no transaction started'); } diff --git a/tests/datasets/storage/database.fixture.php b/tests/datasets/storage/database.fixture.php index 8e2e92ecc2..6a73d4ed2a 100644 --- a/tests/datasets/storage/database.fixture.php +++ b/tests/datasets/storage/database.fixture.php @@ -19,11 +19,43 @@ * */ +use Friendica\Core\Protocol; +use Friendica\Model\Contact; + return [ + 'user' => [ + [ + 'uid' => 42, + 'username' => 'Test user', + 'nickname' => 'selfcontact', + 'verified' => 1, + 'password' => '$2y$10$DLRNTRmJgKe1cSrFJ5Jb0edCqvXlA9sh/RHdSnfxjbR.04yZRm4Qm', + 'theme' => 'frio', + ], + ], + 'contact' => [ + [ + 'id' => 42, + 'uid' => 42, + 'name' => 'Self contact', + 'nick' => 'selfcontact', + 'self' => 1, + 'nurl' => 'http://localhost/profile/selfcontact', + 'url' => 'http://localhost/profile/selfcontact', + 'about' => 'User used in tests', + 'pending' => 0, + 'blocked' => 0, + 'rel' => Contact::FOLLOWER, + 'network' => Protocol::DFRN, + 'location' => 'DFRN', + ], + ], 'photo' => [ // move from data-attribute to storage backend [ 'id' => 1, + 'uid' => 42, + 'contact-id' => 42, 'backend-class' => null, 'backend-ref' => 'f0c0d0i2', 'data' => 'without class', @@ -31,6 +63,8 @@ return [ // move from storage-backend to maybe filesystem backend, skip at database backend [ 'id' => 2, + 'uid' => 42, + 'contact-id' => 42, 'backend-class' => 'Database', 'backend-ref' => 1, 'data' => '', @@ -38,6 +72,8 @@ return [ // move data if invalid storage [ 'id' => 3, + 'uid' => 42, + 'contact-id' => 42, 'backend-class' => 'invalid!', 'backend-ref' => 'unimported', 'data' => 'invalid data moved', @@ -45,6 +81,8 @@ return [ // @todo Check failing test because of this (never loaded) fixture // [ // 'id' => 4, +// 'uid' => 42, +// 'contact-id' => 42, // 'backend-class' => 'invalid!', // 'backend-ref' => 'unimported', // 'data' => '', diff --git a/tests/functional/DependencyCheckTest.php b/tests/functional/DependencyCheckTest.php index b6367ab916..a7b45ccebe 100644 --- a/tests/functional/DependencyCheckTest.php +++ b/tests/functional/DependencyCheckTest.php @@ -45,7 +45,7 @@ class DependencyCheckTest extends TestCase */ private $dice; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index bced7eb197..67daca802a 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -50,7 +50,7 @@ class ApiTest extends FixtureTest /** * Create variables used by tests. */ - protected function setUp() + protected function setUp() : void { global $API, $called_api; $API = []; diff --git a/tests/src/App/ModeTest.php b/tests/src/App/ModeTest.php index b2a19726de..28393c6c26 100644 --- a/tests/src/App/ModeTest.php +++ b/tests/src/App/ModeTest.php @@ -53,7 +53,7 @@ class ModeTest extends MockedTest */ private $configCacheMock; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/App/RouterTest.php b/tests/src/App/RouterTest.php index 8bd7c467f7..a5824c4556 100644 --- a/tests/src/App/RouterTest.php +++ b/tests/src/App/RouterTest.php @@ -40,7 +40,7 @@ class RouterTest extends TestCase */ private $cache; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/Console/AutomaticInstallationConsoleTest.php b/tests/src/Console/AutomaticInstallationConsoleTest.php index d0d03a1b2c..fcb3289b8a 100644 --- a/tests/src/Console/AutomaticInstallationConsoleTest.php +++ b/tests/src/Console/AutomaticInstallationConsoleTest.php @@ -76,7 +76,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest */ private $dice; - public function setUp() + public function setUp() : void { static::markTestSkipped('Needs class \'Installer\' as constructing argument for console tests'); diff --git a/tests/src/Console/ConfigConsoleTest.php b/tests/src/Console/ConfigConsoleTest.php index 59aa07470c..5c670aedfc 100644 --- a/tests/src/Console/ConfigConsoleTest.php +++ b/tests/src/Console/ConfigConsoleTest.php @@ -38,7 +38,7 @@ class ConfigConsoleTest extends ConsoleTest /** @var IConfig|LegacyMockInterface|MockInterface */ private $configMock; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/Console/ConsoleTest.php b/tests/src/Console/ConsoleTest.php index 74fc0530b4..a4315452df 100644 --- a/tests/src/Console/ConsoleTest.php +++ b/tests/src/Console/ConsoleTest.php @@ -32,7 +32,7 @@ abstract class ConsoleTest extends MockedTest */ protected $consoleArgv = [ 'consoleTest.php' ]; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/Console/LockConsoleTest.php b/tests/src/Console/LockConsoleTest.php index aa7f62835c..1f33be100e 100644 --- a/tests/src/Console/LockConsoleTest.php +++ b/tests/src/Console/LockConsoleTest.php @@ -40,7 +40,7 @@ class LockConsoleTest extends ConsoleTest */ private $lockMock; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/Console/ServerBlockConsoleTest.php b/tests/src/Console/ServerBlockConsoleTest.php index 9899bf015a..e19ebf9cbc 100644 --- a/tests/src/Console/ServerBlockConsoleTest.php +++ b/tests/src/Console/ServerBlockConsoleTest.php @@ -42,7 +42,7 @@ class ServerBlockConsoleTest extends ConsoleTest */ private $configMock; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php index a3633cea53..8d4624298c 100644 --- a/tests/src/Content/SmiliesTest.php +++ b/tests/src/Content/SmiliesTest.php @@ -19,7 +19,7 @@ class SmiliesTest extends MockedTest use VFSTrait; use AppMockTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpVfsDir(); diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 0bf281d6ff..46f153edc2 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -35,7 +35,7 @@ class BBCodeTest extends MockedTest use VFSTrait; use AppMockTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpVfsDir(); diff --git a/tests/src/Content/Text/HTMLTest.php b/tests/src/Content/Text/HTMLTest.php index 20106d54a7..bf5e676a9c 100644 --- a/tests/src/Content/Text/HTMLTest.php +++ b/tests/src/Content/Text/HTMLTest.php @@ -33,7 +33,7 @@ class HTMLTest extends MockedTest use VFSTrait; use AppMockTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpVfsDir(); diff --git a/tests/src/Content/Text/MarkdownTest.php b/tests/src/Content/Text/MarkdownTest.php index 2b23b8da42..5fae494d6f 100644 --- a/tests/src/Content/Text/MarkdownTest.php +++ b/tests/src/Content/Text/MarkdownTest.php @@ -32,7 +32,7 @@ class MarkdownTest extends MockedTest use VFSTrait; use AppMockTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->setUpVfsDir(); diff --git a/tests/src/Core/Cache/APCuCacheTest.php b/tests/src/Core/Cache/APCuCacheTest.php index 4e7815ba17..d8fe59da03 100644 --- a/tests/src/Core/Cache/APCuCacheTest.php +++ b/tests/src/Core/Cache/APCuCacheTest.php @@ -28,7 +28,7 @@ use Friendica\Core\Cache\APCuCache; */ class APCuCacheTest extends MemoryCacheTest { - protected function setUp() + protected function setUp(): void { if (!APCuCache::isAvailable()) { static::markTestSkipped('APCu is not available'); @@ -43,7 +43,7 @@ class APCuCacheTest extends MemoryCacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); parent::tearDown(); diff --git a/tests/src/Core/Cache/ArrayCacheTest.php b/tests/src/Core/Cache/ArrayCacheTest.php index 2d8d0ff837..ada1fac654 100644 --- a/tests/src/Core/Cache/ArrayCacheTest.php +++ b/tests/src/Core/Cache/ArrayCacheTest.php @@ -31,7 +31,7 @@ class ArrayCacheTest extends MemoryCacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); parent::tearDown(); diff --git a/tests/src/Core/Cache/CacheTest.php b/tests/src/Core/Cache/CacheTest.php index f491e00e3d..5e5d1c17d5 100644 --- a/tests/src/Core/Cache/CacheTest.php +++ b/tests/src/Core/Cache/CacheTest.php @@ -81,7 +81,7 @@ abstract class CacheTest extends MockedTest abstract protected function getInstance(); - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Core/Cache/DatabaseCacheTest.php b/tests/src/Core/Cache/DatabaseCacheTest.php index cd96b064f1..458f3faa20 100644 --- a/tests/src/Core/Cache/DatabaseCacheTest.php +++ b/tests/src/Core/Cache/DatabaseCacheTest.php @@ -36,10 +36,12 @@ class DatabaseCacheTest extends CacheTest use DatabaseTestTrait; use VFSTrait; - protected function setUp() + protected function setUp(): void { $this->setUpVfsDir(); + $this->setUpDb(); + parent::setUp(); } @@ -60,9 +62,12 @@ class DatabaseCacheTest extends CacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); + + $this->tearDownDb(); + parent::tearDown(); } } diff --git a/tests/src/Core/Cache/MemcacheCacheTest.php b/tests/src/Core/Cache/MemcacheCacheTest.php index 22b95ad2ef..738ff8100f 100644 --- a/tests/src/Core/Cache/MemcacheCacheTest.php +++ b/tests/src/Core/Cache/MemcacheCacheTest.php @@ -56,7 +56,7 @@ class MemcacheCacheTest extends MemoryCacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); parent::tearDown(); diff --git a/tests/src/Core/Cache/MemcachedCacheTest.php b/tests/src/Core/Cache/MemcachedCacheTest.php index 64aaf58fb8..88de1ad41d 100644 --- a/tests/src/Core/Cache/MemcachedCacheTest.php +++ b/tests/src/Core/Cache/MemcachedCacheTest.php @@ -55,7 +55,7 @@ class MemcachedCacheTest extends MemoryCacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); parent::tearDown(); diff --git a/tests/src/Core/Cache/MemoryCacheTest.php b/tests/src/Core/Cache/MemoryCacheTest.php index b2a88e49db..eca25fa694 100644 --- a/tests/src/Core/Cache/MemoryCacheTest.php +++ b/tests/src/Core/Cache/MemoryCacheTest.php @@ -31,7 +31,7 @@ abstract class MemoryCacheTest extends CacheTest */ protected $instance; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Core/Cache/RedisCacheTest.php b/tests/src/Core/Cache/RedisCacheTest.php index 5436d58a50..146dca6d9f 100644 --- a/tests/src/Core/Cache/RedisCacheTest.php +++ b/tests/src/Core/Cache/RedisCacheTest.php @@ -65,7 +65,7 @@ class RedisCacheTest extends MemoryCacheTest return $this->cache; } - protected function tearDown() + protected function tearDown(): void { $this->cache->clear(false); parent::tearDown(); diff --git a/tests/src/Core/Config/ConfigTest.php b/tests/src/Core/Config/ConfigTest.php index 8d140e1c75..734f6bff79 100644 --- a/tests/src/Core/Config/ConfigTest.php +++ b/tests/src/Core/Config/ConfigTest.php @@ -55,7 +55,7 @@ abstract class ConfigTest extends MockedTest } - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php index b3f91e7d33..7404e216e2 100644 --- a/tests/src/Core/InstallerTest.php +++ b/tests/src/Core/InstallerTest.php @@ -45,7 +45,7 @@ class InstallerTest extends MockedTest */ private $dice; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -64,6 +64,15 @@ class InstallerTest extends MockedTest DI::init($this->dice); } + public static function tearDownAfterClass(): void + { + // Reset mocking + global $phpMock; + $phpMock = []; + + parent::tearDownAfterClass(); + } + private function mockL10nT(string $text, $times = null) { $this->l10nMock->shouldReceive('t')->with($text)->andReturn($text)->times($times); @@ -467,7 +476,7 @@ class InstallerTest extends MockedTest */ public function testSetUpCache() { - $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; })->times(5); + $this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; }); $install = new Installer(); $configCache = Mockery::mock(Cache::class); diff --git a/tests/src/Core/Lock/APCuCacheLockTest.php b/tests/src/Core/Lock/APCuCacheLockTest.php index bbcbfe54ad..9f893ab324 100644 --- a/tests/src/Core/Lock/APCuCacheLockTest.php +++ b/tests/src/Core/Lock/APCuCacheLockTest.php @@ -29,7 +29,7 @@ use Friendica\Core\Lock\CacheLock; */ class APCuCacheLockTest extends LockTest { - protected function setUp() + protected function setUp(): void { if (!APCuCache::isAvailable()) { static::markTestSkipped('APCu is not available'); diff --git a/tests/src/Core/Lock/DatabaseLockDriverTest.php b/tests/src/Core/Lock/DatabaseLockDriverTest.php index fa120e03ab..bc4a9a63b8 100644 --- a/tests/src/Core/Lock/DatabaseLockDriverTest.php +++ b/tests/src/Core/Lock/DatabaseLockDriverTest.php @@ -38,10 +38,12 @@ class DatabaseLockDriverTest extends LockTest protected $pid = 123; - protected function setUp() + protected function setUp(): void { $this->setUpVfsDir(); + $this->setUpDb(); + parent::setUp(); } @@ -60,4 +62,11 @@ class DatabaseLockDriverTest extends LockTest return new DatabaseLock($dba, $this->pid); } + + protected function tearDown(): void + { + $this->tearDownDb(); + + parent::tearDown(); + } } diff --git a/tests/src/Core/Lock/LockTest.php b/tests/src/Core/Lock/LockTest.php index 3b7496915a..8fc4926b06 100644 --- a/tests/src/Core/Lock/LockTest.php +++ b/tests/src/Core/Lock/LockTest.php @@ -38,7 +38,7 @@ abstract class LockTest extends MockedTest abstract protected function getInstance(); - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -46,7 +46,7 @@ abstract class LockTest extends MockedTest $this->instance->releaseAll(true); } - protected function tearDown() + protected function tearDown(): void { $this->instance->releaseAll(true); parent::tearDown(); diff --git a/tests/src/Core/Lock/SemaphoreLockTest.php b/tests/src/Core/Lock/SemaphoreLockTest.php index 71273fdc2c..ca5d0af7db 100644 --- a/tests/src/Core/Lock/SemaphoreLockTest.php +++ b/tests/src/Core/Lock/SemaphoreLockTest.php @@ -32,7 +32,7 @@ use Mockery\MockInterface; class SemaphoreLockTest extends LockTest { - protected function setUp() + protected function setUp(): void { /** @var MockInterface|Dice $dice */ $dice = Mockery::mock(Dice::class)->makePartial(); diff --git a/tests/src/Core/PConfig/PConfigTest.php b/tests/src/Core/PConfig/PConfigTest.php index 9b796e2fe8..f35aa10d98 100644 --- a/tests/src/Core/PConfig/PConfigTest.php +++ b/tests/src/Core/PConfig/PConfigTest.php @@ -57,7 +57,7 @@ abstract class PConfigTest extends MockedTest } - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Core/StorageManagerTest.php b/tests/src/Core/StorageManagerTest.php index 965eb05558..d2078c7e2a 100644 --- a/tests/src/Core/StorageManagerTest.php +++ b/tests/src/Core/StorageManagerTest.php @@ -57,7 +57,7 @@ class StorageManagerTest extends DatabaseTest use VFSTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -296,7 +296,7 @@ class StorageManagerTest extends DatabaseTest public function testMoveStorage($name, $assert, $assertName, $userBackend) { if (!$userBackend) { - return; + self::markTestSkipped("No user backend"); } $this->loadFixture(__DIR__ . '/../../datasets/storage/database.fixture.php', $this->dba); diff --git a/tests/src/Database/DBATest.php b/tests/src/Database/DBATest.php index c013dcda83..b5dbf2f2c5 100644 --- a/tests/src/Database/DBATest.php +++ b/tests/src/Database/DBATest.php @@ -10,7 +10,7 @@ use Friendica\Test\Util\Database\StaticDatabase; class DBATest extends DatabaseTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Database/DBStructureTest.php b/tests/src/Database/DBStructureTest.php index 03aa34b8cb..87535b5a3e 100644 --- a/tests/src/Database/DBStructureTest.php +++ b/tests/src/Database/DBStructureTest.php @@ -30,7 +30,7 @@ use Friendica\Test\Util\Database\StaticDatabase; class DBStructureTest extends DatabaseTest { - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Model/ProcessTest.php b/tests/src/Model/ProcessTest.php index fb02f62ff1..b6e610238e 100644 --- a/tests/src/Model/ProcessTest.php +++ b/tests/src/Model/ProcessTest.php @@ -18,7 +18,7 @@ class ProcessTest extends DatabaseTest /** @var StaticDatabase */ private $dba; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -71,6 +71,9 @@ class ProcessTest extends DatabaseTest self::assertEquals([['command' => 'test']], $this->dba->selectToArray('process', ['command'], ['pid' => 1])); } + /** + * @doesNotPerformAssertions + */ public function testWrongDelete() { $process = new Process($this->dba); diff --git a/tests/src/Model/Storage/DatabaseStorageTest.php b/tests/src/Model/Storage/DatabaseStorageTest.php index 1952678e8c..45793b47af 100644 --- a/tests/src/Model/Storage/DatabaseStorageTest.php +++ b/tests/src/Model/Storage/DatabaseStorageTest.php @@ -38,10 +38,12 @@ class DatabaseStorageTest extends StorageTest use DatabaseTestTrait; use VFSTrait; - protected function setUp() + protected function setUp(): void { $this->setUpVfsDir(); + $this->setUpDb(); + parent::setUp(); } @@ -68,4 +70,11 @@ class DatabaseStorageTest extends StorageTest { self::assertEmpty($storage->getOptions()); } + + protected function tearDown(): void + { + $this->tearDownDb(); + + parent::tearDown(); + } } diff --git a/tests/src/Model/Storage/FilesystemStorageTest.php b/tests/src/Model/Storage/FilesystemStorageTest.php index 844197da53..6d50e06c40 100644 --- a/tests/src/Model/Storage/FilesystemStorageTest.php +++ b/tests/src/Model/Storage/FilesystemStorageTest.php @@ -39,7 +39,7 @@ class FilesystemStorageTest extends StorageTest /** @var MockInterface|IConfig */ protected $config; - protected function setUp() + protected function setUp(): void { $this->setUpVfsDir(); diff --git a/tests/src/Model/User/CookieTest.php b/tests/src/Model/User/CookieTest.php index 2be1962d42..c9656b84f8 100644 --- a/tests/src/Model/User/CookieTest.php +++ b/tests/src/Model/User/CookieTest.php @@ -35,7 +35,7 @@ class CookieTest extends MockedTest /** @var MockInterface|BaseURL */ private $baseUrl; - protected function setUp() + protected function setUp(): void { StaticCookie::clearStatic(); @@ -45,7 +45,7 @@ class CookieTest extends MockedTest $this->baseUrl = \Mockery::mock(BaseURL::class); } - protected function tearDown() + protected function tearDown(): void { StaticCookie::clearStatic(); diff --git a/tests/src/Model/UserTest.php b/tests/src/Model/UserTest.php index d754adde79..8f8b2c3d7d 100644 --- a/tests/src/Model/UserTest.php +++ b/tests/src/Model/UserTest.php @@ -37,7 +37,7 @@ class UserTest extends MockedTest private $child; private $manage; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Network/CurlResultTest.php b/tests/src/Network/CurlResultTest.php index 47bec3e687..090479642a 100644 --- a/tests/src/Network/CurlResultTest.php +++ b/tests/src/Network/CurlResultTest.php @@ -31,7 +31,7 @@ use Psr\Log\NullLogger; class CurlResultTest extends TestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Config/ConfigFileLoaderTest.php b/tests/src/Util/Config/ConfigFileLoaderTest.php index d197450495..781e1415f7 100644 --- a/tests/src/Util/Config/ConfigFileLoaderTest.php +++ b/tests/src/Util/Config/ConfigFileLoaderTest.php @@ -31,7 +31,7 @@ class ConfigFileLoaderTest extends MockedTest { use VFSTrait; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/CryptoTest.php b/tests/src/Util/CryptoTest.php index c9263ffccf..16770ff649 100644 --- a/tests/src/Util/CryptoTest.php +++ b/tests/src/Util/CryptoTest.php @@ -29,6 +29,15 @@ use PHPUnit\Framework\TestCase; class CryptoTest extends TestCase { + public static function tearDownAfterClass(): void + { + // Reset mocking + global $phpMock; + $phpMock = []; + + parent::tearDownAfterClass(); + } + /** * Replaces random_int results with given mocks * diff --git a/tests/src/Util/EMailerTest.php b/tests/src/Util/EMailerTest.php index 523d3de122..3b1c3cc1f3 100644 --- a/tests/src/Util/EMailerTest.php +++ b/tests/src/Util/EMailerTest.php @@ -35,7 +35,7 @@ class EMailerTest extends MockedTest /** @var BaseURL|MockInterface */ private $baseUrl; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -53,7 +53,7 @@ class EMailerTest extends MockedTest $this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local'); } - protected function tearDown() + protected function tearDown(): void { EmailerSpy::$MAIL_DATA = []; diff --git a/tests/src/Util/Emailer/MailBuilderTest.php b/tests/src/Util/Emailer/MailBuilderTest.php index e260928892..933203d156 100644 --- a/tests/src/Util/Emailer/MailBuilderTest.php +++ b/tests/src/Util/Emailer/MailBuilderTest.php @@ -51,7 +51,7 @@ class MailBuilderTest extends MockedTest /** @var string */ private $defaultHeaders; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Emailer/SystemMailBuilderTest.php b/tests/src/Util/Emailer/SystemMailBuilderTest.php index 4ee81a7c91..87b51030f7 100644 --- a/tests/src/Util/Emailer/SystemMailBuilderTest.php +++ b/tests/src/Util/Emailer/SystemMailBuilderTest.php @@ -41,7 +41,7 @@ class SystemMailBuilderTest extends MockedTest /** @var BaseURL */ private $baseUrl; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Logger/AbstractLoggerTest.php b/tests/src/Util/Logger/AbstractLoggerTest.php index 5c87d1cf41..44e210b9ca 100644 --- a/tests/src/Util/Logger/AbstractLoggerTest.php +++ b/tests/src/Util/Logger/AbstractLoggerTest.php @@ -58,7 +58,7 @@ abstract class AbstractLoggerTest extends MockedTest */ abstract protected function getInstance($level = LogLevel::DEBUG); - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Logger/ProfilerLoggerTest.php b/tests/src/Util/Logger/ProfilerLoggerTest.php index 9dd82b4276..7719292b09 100644 --- a/tests/src/Util/Logger/ProfilerLoggerTest.php +++ b/tests/src/Util/Logger/ProfilerLoggerTest.php @@ -41,7 +41,7 @@ class ProfilerLoggerTest extends MockedTest */ private $profiler; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Logger/StreamLoggerTest.php b/tests/src/Util/Logger/StreamLoggerTest.php index d0cf87e970..7a3315e7ef 100644 --- a/tests/src/Util/Logger/StreamLoggerTest.php +++ b/tests/src/Util/Logger/StreamLoggerTest.php @@ -42,7 +42,7 @@ class StreamLoggerTest extends AbstractLoggerTest */ private $fileSystem; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Util/Logger/SyslogLoggerTest.php b/tests/src/Util/Logger/SyslogLoggerTest.php index 61c0d874a8..9408495e74 100644 --- a/tests/src/Util/Logger/SyslogLoggerTest.php +++ b/tests/src/Util/Logger/SyslogLoggerTest.php @@ -31,7 +31,7 @@ class SyslogLoggerTest extends AbstractLoggerTest */ private $logger; - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -86,8 +86,13 @@ class SyslogLoggerTest extends AbstractLoggerTest */ public function testServerException() { - $this->expectException(\UnexpectedValueException::class); - $this->expectExceptionMessageRegExp("/Can\'t open syslog for ident \".*\" and facility \".*\": .* /"); + if (PHP_MAJOR_VERSION < 8) { + $this->expectException(\UnexpectedValueException::class); + $this->expectExceptionMessageRegExp("/Can\'t open syslog for ident \".*\" and facility \".*\": .* /"); + } else { + $this->expectException(\TypeError::class); + $this->expectExceptionMessage("openlog(): Argument #3 (\$facility) must be of type int, string given"); + } $logger = new SyslogLoggerWrapper('test', $this->introspection, LogLevel::DEBUG, null, 'a string'); $logger->emergency('not working'); diff --git a/tests/src/Util/ProfilerTest.php b/tests/src/Util/ProfilerTest.php index b0176f0fdb..da0546d1be 100644 --- a/tests/src/Util/ProfilerTest.php +++ b/tests/src/Util/ProfilerTest.php @@ -35,7 +35,7 @@ class ProfilerTest extends MockedTest */ private $logger; - protected function setUp() + protected function setUp(): void { parent::setUp();