mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 08:14:25 +02:00
Fix tests
- Fix InstallerTest case - Fix native function mocking - Add returntype for Unit-Tests - Fixing ExtendedPDO test troubles - Fix wrong class inheritance path for DatabaseTestTrait.php - Fix SyslogLogger Server Exception for PHP8 - Add user/contact to database.fixture.php - Avoid invalid rollbacks for test setup in PHP8
This commit is contained in:
parent
8cab5edea9
commit
02e6dff6a0
53 changed files with 171 additions and 69 deletions
|
@ -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();
|
||||
|
|
|
@ -31,7 +31,7 @@ class ArrayCacheTest extends MemoryCacheTest
|
|||
return $this->cache;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cache->clear(false);
|
||||
parent::tearDown();
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class CacheTest extends MockedTest
|
|||
|
||||
abstract protected function getInstance();
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class MemcacheCacheTest extends MemoryCacheTest
|
|||
return $this->cache;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cache->clear(false);
|
||||
parent::tearDown();
|
||||
|
|
|
@ -55,7 +55,7 @@ class MemcachedCacheTest extends MemoryCacheTest
|
|||
return $this->cache;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cache->clear(false);
|
||||
parent::tearDown();
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract class MemoryCacheTest extends CacheTest
|
|||
*/
|
||||
protected $instance;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class RedisCacheTest extends MemoryCacheTest
|
|||
return $this->cache;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->cache->clear(false);
|
||||
parent::tearDown();
|
||||
|
|
|
@ -55,7 +55,7 @@ abstract class ConfigTest extends MockedTest
|
|||
}
|
||||
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -57,7 +57,7 @@ abstract class PConfigTest extends MockedTest
|
|||
}
|
||||
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue