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
|
@ -27,4 +27,18 @@ namespace Friendica\Test;
|
||||||
abstract class DatabaseTest extends MockedTest
|
abstract class DatabaseTest extends MockedTest
|
||||||
{
|
{
|
||||||
use DatabaseTestTrait;
|
use DatabaseTestTrait;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->setUpDb();
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
$this->tearDownDb();
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,23 +29,23 @@ use Friendica\Test\Util\Database\StaticDatabase;
|
||||||
*/
|
*/
|
||||||
trait DatabaseTestTrait
|
trait DatabaseTestTrait
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUpDb()
|
||||||
{
|
{
|
||||||
StaticDatabase::statConnect($_SERVER);
|
StaticDatabase::statConnect($_SERVER);
|
||||||
// Rollbacks every DB usage (in case the test couldn't call tearDown)
|
// Rollbacks every DB usage (in case the test couldn't call tearDown)
|
||||||
StaticDatabase::statRollback();
|
StaticDatabase::statRollback();
|
||||||
// Start the first, outer transaction
|
// Start the first, outer transaction
|
||||||
StaticDatabase::getGlobConnection()->beginTransaction();
|
StaticDatabase::getGlobConnection()->beginTransaction();
|
||||||
|
|
||||||
parent::setUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDownDb()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
// Rollbacks every DB usage so we don't commit anything into the DB
|
// Rollbacks every DB usage so we don't commit anything into the DB
|
||||||
StaticDatabase::statRollback();
|
StaticDatabase::statRollback();
|
||||||
|
} catch (\PDOException $exception) {
|
||||||
parent::tearDown();
|
print_r("Found already rolled back transaction");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,7 @@ abstract class FixtureTest extends DatabaseTest
|
||||||
/**
|
/**
|
||||||
* Create variables used by tests.
|
* Create variables used by tests.
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ use PHPUnit\Framework\TestCase;
|
||||||
*/
|
*/
|
||||||
abstract class MockedTest extends TestCase
|
abstract class MockedTest extends TestCase
|
||||||
{
|
{
|
||||||
protected function tearDown()
|
protected function tearDown() : void
|
||||||
{
|
{
|
||||||
\Mockery::close();
|
\Mockery::close();
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,9 @@ class ExtendedPDO extends PDO
|
||||||
*/
|
*/
|
||||||
public function beginTransaction()
|
public function beginTransaction()
|
||||||
{
|
{
|
||||||
if($this->_transactionDepth == 0 || !$this->hasSavepoint()) {
|
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
|
||||||
parent::beginTransaction();
|
parent::beginTransaction();
|
||||||
|
$this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth;
|
||||||
} else {
|
} else {
|
||||||
$this->exec("SAVEPOINT LEVEL{$this->_transactionDepth}");
|
$this->exec("SAVEPOINT LEVEL{$this->_transactionDepth}");
|
||||||
}
|
}
|
||||||
|
@ -85,8 +86,9 @@ class ExtendedPDO extends PDO
|
||||||
{
|
{
|
||||||
$this->_transactionDepth--;
|
$this->_transactionDepth--;
|
||||||
|
|
||||||
if($this->_transactionDepth == 0 || !$this->hasSavepoint()) {
|
if($this->_transactionDepth <= 0 || !$this->hasSavepoint()) {
|
||||||
parent::commit();
|
parent::commit();
|
||||||
|
$this->_transactionDepth = $this->_transactionDepth < 0 ? 0 : $this->_transactionDepth;
|
||||||
} else {
|
} else {
|
||||||
$this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
|
$this->exec("RELEASE SAVEPOINT LEVEL{$this->_transactionDepth}");
|
||||||
}
|
}
|
||||||
|
@ -100,8 +102,7 @@ class ExtendedPDO extends PDO
|
||||||
*/
|
*/
|
||||||
public function rollBack()
|
public function rollBack()
|
||||||
{
|
{
|
||||||
|
if ($this->_transactionDepth <= 0) {
|
||||||
if ($this->_transactionDepth == 0) {
|
|
||||||
throw new PDOException('Rollback error : There is no transaction started');
|
throw new PDOException('Rollback error : There is no transaction started');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,43 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
|
|
||||||
return [
|
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' => [
|
'photo' => [
|
||||||
// move from data-attribute to storage backend
|
// move from data-attribute to storage backend
|
||||||
[
|
[
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
|
'uid' => 42,
|
||||||
|
'contact-id' => 42,
|
||||||
'backend-class' => null,
|
'backend-class' => null,
|
||||||
'backend-ref' => 'f0c0d0i2',
|
'backend-ref' => 'f0c0d0i2',
|
||||||
'data' => 'without class',
|
'data' => 'without class',
|
||||||
|
@ -31,6 +63,8 @@ return [
|
||||||
// move from storage-backend to maybe filesystem backend, skip at database backend
|
// move from storage-backend to maybe filesystem backend, skip at database backend
|
||||||
[
|
[
|
||||||
'id' => 2,
|
'id' => 2,
|
||||||
|
'uid' => 42,
|
||||||
|
'contact-id' => 42,
|
||||||
'backend-class' => 'Database',
|
'backend-class' => 'Database',
|
||||||
'backend-ref' => 1,
|
'backend-ref' => 1,
|
||||||
'data' => '',
|
'data' => '',
|
||||||
|
@ -38,6 +72,8 @@ return [
|
||||||
// move data if invalid storage
|
// move data if invalid storage
|
||||||
[
|
[
|
||||||
'id' => 3,
|
'id' => 3,
|
||||||
|
'uid' => 42,
|
||||||
|
'contact-id' => 42,
|
||||||
'backend-class' => 'invalid!',
|
'backend-class' => 'invalid!',
|
||||||
'backend-ref' => 'unimported',
|
'backend-ref' => 'unimported',
|
||||||
'data' => 'invalid data moved',
|
'data' => 'invalid data moved',
|
||||||
|
@ -45,6 +81,8 @@ return [
|
||||||
// @todo Check failing test because of this (never loaded) fixture
|
// @todo Check failing test because of this (never loaded) fixture
|
||||||
// [
|
// [
|
||||||
// 'id' => 4,
|
// 'id' => 4,
|
||||||
|
// 'uid' => 42,
|
||||||
|
// 'contact-id' => 42,
|
||||||
// 'backend-class' => 'invalid!',
|
// 'backend-class' => 'invalid!',
|
||||||
// 'backend-ref' => 'unimported',
|
// 'backend-ref' => 'unimported',
|
||||||
// 'data' => '',
|
// 'data' => '',
|
||||||
|
|
|
@ -45,7 +45,7 @@ class DependencyCheckTest extends TestCase
|
||||||
*/
|
*/
|
||||||
private $dice;
|
private $dice;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class ApiTest extends FixtureTest
|
||||||
/**
|
/**
|
||||||
* Create variables used by tests.
|
* Create variables used by tests.
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
global $API, $called_api;
|
global $API, $called_api;
|
||||||
$API = [];
|
$API = [];
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ModeTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
private $configCacheMock;
|
private $configCacheMock;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class RouterTest extends TestCase
|
||||||
*/
|
*/
|
||||||
private $cache;
|
private $cache;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||||
*/
|
*/
|
||||||
private $dice;
|
private $dice;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp() : void
|
||||||
{
|
{
|
||||||
static::markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
static::markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ConfigConsoleTest extends ConsoleTest
|
||||||
/** @var IConfig|LegacyMockInterface|MockInterface */
|
/** @var IConfig|LegacyMockInterface|MockInterface */
|
||||||
private $configMock;
|
private $configMock;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ abstract class ConsoleTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
protected $consoleArgv = [ 'consoleTest.php' ];
|
protected $consoleArgv = [ 'consoleTest.php' ];
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class LockConsoleTest extends ConsoleTest
|
||||||
*/
|
*/
|
||||||
private $lockMock;
|
private $lockMock;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ServerBlockConsoleTest extends ConsoleTest
|
||||||
*/
|
*/
|
||||||
private $configMock;
|
private $configMock;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp() : void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SmiliesTest extends MockedTest
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
|
@ -35,7 +35,7 @@ class BBCodeTest extends MockedTest
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class HTMLTest extends MockedTest
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
|
@ -32,7 +32,7 @@ class MarkdownTest extends MockedTest
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
use AppMockTrait;
|
use AppMockTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Core\Cache\APCuCache;
|
||||||
*/
|
*/
|
||||||
class APCuCacheTest extends MemoryCacheTest
|
class APCuCacheTest extends MemoryCacheTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
if (!APCuCache::isAvailable()) {
|
if (!APCuCache::isAvailable()) {
|
||||||
static::markTestSkipped('APCu is not available');
|
static::markTestSkipped('APCu is not available');
|
||||||
|
@ -43,7 +43,7 @@ class APCuCacheTest extends MemoryCacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ArrayCacheTest extends MemoryCacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -81,7 +81,7 @@ abstract class CacheTest extends MockedTest
|
||||||
|
|
||||||
abstract protected function getInstance();
|
abstract protected function getInstance();
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,12 @@ class DatabaseCacheTest extends CacheTest
|
||||||
use DatabaseTestTrait;
|
use DatabaseTestTrait;
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
||||||
|
$this->setUpDb();
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +62,12 @@ class DatabaseCacheTest extends CacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
|
|
||||||
|
$this->tearDownDb();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ class MemcacheCacheTest extends MemoryCacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -55,7 +55,7 @@ class MemcachedCacheTest extends MemoryCacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -31,7 +31,7 @@ abstract class MemoryCacheTest extends CacheTest
|
||||||
*/
|
*/
|
||||||
protected $instance;
|
protected $instance;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class RedisCacheTest extends MemoryCacheTest
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->cache->clear(false);
|
$this->cache->clear(false);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -55,7 +55,7 @@ abstract class ConfigTest extends MockedTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class InstallerTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
private $dice;
|
private $dice;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -64,6 +64,15 @@ class InstallerTest extends MockedTest
|
||||||
DI::init($this->dice);
|
DI::init($this->dice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function tearDownAfterClass(): void
|
||||||
|
{
|
||||||
|
// Reset mocking
|
||||||
|
global $phpMock;
|
||||||
|
$phpMock = [];
|
||||||
|
|
||||||
|
parent::tearDownAfterClass();
|
||||||
|
}
|
||||||
|
|
||||||
private function mockL10nT(string $text, $times = null)
|
private function mockL10nT(string $text, $times = null)
|
||||||
{
|
{
|
||||||
$this->l10nMock->shouldReceive('t')->with($text)->andReturn($text)->times($times);
|
$this->l10nMock->shouldReceive('t')->with($text)->andReturn($text)->times($times);
|
||||||
|
@ -467,7 +476,7 @@ class InstallerTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testSetUpCache()
|
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();
|
$install = new Installer();
|
||||||
$configCache = Mockery::mock(Cache::class);
|
$configCache = Mockery::mock(Cache::class);
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Friendica\Core\Lock\CacheLock;
|
||||||
*/
|
*/
|
||||||
class APCuCacheLockTest extends LockTest
|
class APCuCacheLockTest extends LockTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
if (!APCuCache::isAvailable()) {
|
if (!APCuCache::isAvailable()) {
|
||||||
static::markTestSkipped('APCu is not available');
|
static::markTestSkipped('APCu is not available');
|
||||||
|
|
|
@ -38,10 +38,12 @@ class DatabaseLockDriverTest extends LockTest
|
||||||
|
|
||||||
protected $pid = 123;
|
protected $pid = 123;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
||||||
|
$this->setUpDb();
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,4 +62,11 @@ class DatabaseLockDriverTest extends LockTest
|
||||||
|
|
||||||
return new DatabaseLock($dba, $this->pid);
|
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();
|
abstract protected function getInstance();
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ abstract class LockTest extends MockedTest
|
||||||
$this->instance->releaseAll(true);
|
$this->instance->releaseAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
$this->instance->releaseAll(true);
|
$this->instance->releaseAll(true);
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
|
|
|
@ -32,7 +32,7 @@ use Mockery\MockInterface;
|
||||||
|
|
||||||
class SemaphoreLockTest extends LockTest
|
class SemaphoreLockTest extends LockTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
/** @var MockInterface|Dice $dice */
|
/** @var MockInterface|Dice $dice */
|
||||||
$dice = Mockery::mock(Dice::class)->makePartial();
|
$dice = Mockery::mock(Dice::class)->makePartial();
|
||||||
|
|
|
@ -57,7 +57,7 @@ abstract class PConfigTest extends MockedTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class StorageManagerTest extends DatabaseTest
|
||||||
|
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ class StorageManagerTest extends DatabaseTest
|
||||||
public function testMoveStorage($name, $assert, $assertName, $userBackend)
|
public function testMoveStorage($name, $assert, $assertName, $userBackend)
|
||||||
{
|
{
|
||||||
if (!$userBackend) {
|
if (!$userBackend) {
|
||||||
return;
|
self::markTestSkipped("No user backend");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadFixture(__DIR__ . '/../../datasets/storage/database.fixture.php', $this->dba);
|
$this->loadFixture(__DIR__ . '/../../datasets/storage/database.fixture.php', $this->dba);
|
||||||
|
|
|
@ -10,7 +10,7 @@ use Friendica\Test\Util\Database\StaticDatabase;
|
||||||
|
|
||||||
class DBATest extends DatabaseTest
|
class DBATest extends DatabaseTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\Test\Util\Database\StaticDatabase;
|
||||||
|
|
||||||
class DBStructureTest extends DatabaseTest
|
class DBStructureTest extends DatabaseTest
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ProcessTest extends DatabaseTest
|
||||||
/** @var StaticDatabase */
|
/** @var StaticDatabase */
|
||||||
private $dba;
|
private $dba;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -71,6 +71,9 @@ class ProcessTest extends DatabaseTest
|
||||||
self::assertEquals([['command' => 'test']], $this->dba->selectToArray('process', ['command'], ['pid' => 1]));
|
self::assertEquals([['command' => 'test']], $this->dba->selectToArray('process', ['command'], ['pid' => 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @doesNotPerformAssertions
|
||||||
|
*/
|
||||||
public function testWrongDelete()
|
public function testWrongDelete()
|
||||||
{
|
{
|
||||||
$process = new Process($this->dba);
|
$process = new Process($this->dba);
|
||||||
|
|
|
@ -38,10 +38,12 @@ class DatabaseStorageTest extends StorageTest
|
||||||
use DatabaseTestTrait;
|
use DatabaseTestTrait;
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
||||||
|
$this->setUpDb();
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,4 +70,11 @@ class DatabaseStorageTest extends StorageTest
|
||||||
{
|
{
|
||||||
self::assertEmpty($storage->getOptions());
|
self::assertEmpty($storage->getOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown(): void
|
||||||
|
{
|
||||||
|
$this->tearDownDb();
|
||||||
|
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class FilesystemStorageTest extends StorageTest
|
||||||
/** @var MockInterface|IConfig */
|
/** @var MockInterface|IConfig */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class CookieTest extends MockedTest
|
||||||
/** @var MockInterface|BaseURL */
|
/** @var MockInterface|BaseURL */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
StaticCookie::clearStatic();
|
StaticCookie::clearStatic();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class CookieTest extends MockedTest
|
||||||
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
StaticCookie::clearStatic();
|
StaticCookie::clearStatic();
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class UserTest extends MockedTest
|
||||||
private $child;
|
private $child;
|
||||||
private $manage;
|
private $manage;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Psr\Log\NullLogger;
|
||||||
|
|
||||||
class CurlResultTest extends TestCase
|
class CurlResultTest extends TestCase
|
||||||
{
|
{
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class ConfigFileLoaderTest extends MockedTest
|
||||||
{
|
{
|
||||||
use VFSTrait;
|
use VFSTrait;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,15 @@ use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class CryptoTest extends TestCase
|
class CryptoTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public static function tearDownAfterClass(): void
|
||||||
|
{
|
||||||
|
// Reset mocking
|
||||||
|
global $phpMock;
|
||||||
|
$phpMock = [];
|
||||||
|
|
||||||
|
parent::tearDownAfterClass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces random_int results with given mocks
|
* Replaces random_int results with given mocks
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,7 +35,7 @@ class EMailerTest extends MockedTest
|
||||||
/** @var BaseURL|MockInterface */
|
/** @var BaseURL|MockInterface */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class EMailerTest extends MockedTest
|
||||||
$this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
|
$this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
EmailerSpy::$MAIL_DATA = [];
|
EmailerSpy::$MAIL_DATA = [];
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class MailBuilderTest extends MockedTest
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $defaultHeaders;
|
private $defaultHeaders;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class SystemMailBuilderTest extends MockedTest
|
||||||
/** @var BaseURL */
|
/** @var BaseURL */
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ abstract class AbstractLoggerTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
abstract protected function getInstance($level = LogLevel::DEBUG);
|
abstract protected function getInstance($level = LogLevel::DEBUG);
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ProfilerLoggerTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
private $profiler;
|
private $profiler;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class StreamLoggerTest extends AbstractLoggerTest
|
||||||
*/
|
*/
|
||||||
private $fileSystem;
|
private $fileSystem;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class SyslogLoggerTest extends AbstractLoggerTest
|
||||||
*/
|
*/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -86,8 +86,13 @@ class SyslogLoggerTest extends AbstractLoggerTest
|
||||||
*/
|
*/
|
||||||
public function testServerException()
|
public function testServerException()
|
||||||
{
|
{
|
||||||
|
if (PHP_MAJOR_VERSION < 8) {
|
||||||
$this->expectException(\UnexpectedValueException::class);
|
$this->expectException(\UnexpectedValueException::class);
|
||||||
$this->expectExceptionMessageRegExp("/Can\'t open syslog for ident \".*\" and facility \".*\": .* /");
|
$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 = new SyslogLoggerWrapper('test', $this->introspection, LogLevel::DEBUG, null, 'a string');
|
||||||
$logger->emergency('not working');
|
$logger->emergency('not working');
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ProfilerTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user