Fix a lot of notices/warnings/deprecation notes in the test directory
This commit is contained in:
parent
efaec26b1d
commit
d55ecb9288
77 changed files with 428 additions and 558 deletions
|
@ -32,7 +32,7 @@ class APCuCacheLockTest extends LockTest
|
|||
protected function setUp()
|
||||
{
|
||||
if (!APCuCache::isAvailable()) {
|
||||
$this->markTestSkipped('APCu is not available');
|
||||
static::markTestSkipped('APCu is not available');
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Test\Util\Database\StaticDatabase;
|
|||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Util\ConfigFileLoader;
|
||||
use Friendica\Util\Profiler;
|
||||
use Mockery;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
class DatabaseLockDriverTest extends LockTest
|
||||
|
@ -47,7 +48,7 @@ class DatabaseLockDriverTest extends LockTest
|
|||
protected function getInstance()
|
||||
{
|
||||
$logger = new NullLogger();
|
||||
$profiler = \Mockery::mock(Profiler::class);
|
||||
$profiler = Mockery::mock(Profiler::class);
|
||||
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
|
||||
|
||||
// load real config to avoid mocking every config-entry which is related to the Database class
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Lock;
|
||||
|
||||
use Friendica\Core\Lock\ILock;
|
||||
use Friendica\Test\MockedTest;
|
||||
|
||||
abstract class LockTest extends MockedTest
|
||||
|
@ -31,7 +32,7 @@ abstract class LockTest extends MockedTest
|
|||
protected $startTime = 1417011228;
|
||||
|
||||
/**
|
||||
* @var \Friendica\Core\Lock\ILock
|
||||
* @var ILock
|
||||
*/
|
||||
protected $instance;
|
||||
|
||||
|
@ -185,9 +186,9 @@ abstract class LockTest extends MockedTest
|
|||
/**
|
||||
* @medium
|
||||
*/
|
||||
function testLockTTL()
|
||||
public function testLockTTL()
|
||||
{
|
||||
$this->markTestSkipped('taking too much time without mocking');
|
||||
static::markTestSkipped('taking too much time without mocking');
|
||||
|
||||
self::assertFalse($this->instance->isLocked('foo'));
|
||||
self::assertFalse($this->instance->isLocked('bar'));
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Lock;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Cache\MemcacheCache;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Friendica\Core\Lock\CacheLock;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* @requires extension Memcache
|
||||
|
@ -33,7 +35,7 @@ class MemcacheCacheLockTest extends LockTest
|
|||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$configMock = \Mockery::mock(IConfig::class);
|
||||
$configMock = Mockery::mock(IConfig::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
|
||||
$port = $_SERVER['MEMCACHE_PORT'] ?? '11211';
|
||||
|
@ -52,8 +54,8 @@ class MemcacheCacheLockTest extends LockTest
|
|||
try {
|
||||
$cache = new MemcacheCache($host, $configMock);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Memcache is not available');
|
||||
} catch (Exception $e) {
|
||||
static::markTestSkipped('Memcache is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
|
@ -64,7 +66,7 @@ class MemcacheCacheLockTest extends LockTest
|
|||
*/
|
||||
public function testGetLocks()
|
||||
{
|
||||
$this->markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
||||
static::markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +74,6 @@ class MemcacheCacheLockTest extends LockTest
|
|||
*/
|
||||
public function testGetLocksWithPrefix()
|
||||
{
|
||||
$this->markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
||||
static::markTestIncomplete('Race condition because of too fast getAllKeys() which uses a workaround');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Lock;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Cache\MemcachedCache;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Friendica\Core\Lock\CacheLock;
|
||||
use Mockery;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +36,7 @@ class MemcachedCacheLockTest extends LockTest
|
|||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$configMock = \Mockery::mock(IConfig::class);
|
||||
$configMock = Mockery::mock(IConfig::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
|
||||
$port = $_SERVER['MEMCACHED_PORT'] ?? '11211';
|
||||
|
@ -51,8 +53,8 @@ class MemcachedCacheLockTest extends LockTest
|
|||
try {
|
||||
$cache = new MemcachedCache($host, $configMock, $logger);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Memcached is not available');
|
||||
} catch (Exception $e) {
|
||||
static::markTestSkipped('Memcached is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
|
@ -60,11 +62,11 @@ class MemcachedCacheLockTest extends LockTest
|
|||
|
||||
public function testGetLocks()
|
||||
{
|
||||
$this->markTestIncomplete('Race condition because of too fast getLocks() which uses a workaround');
|
||||
static::markTestIncomplete('Race condition because of too fast getLocks() which uses a workaround');
|
||||
}
|
||||
|
||||
public function testGetLocksWithPrefix()
|
||||
{
|
||||
$this->markTestIncomplete('Race condition because of too fast getLocks() which uses a workaround');
|
||||
static::markTestIncomplete('Race condition because of too fast getLocks() which uses a workaround');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Lock;
|
||||
|
||||
use Exception;
|
||||
use Friendica\Core\Cache\RedisCache;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Friendica\Core\Lock\CacheLock;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* @requires extension redis
|
||||
|
@ -33,7 +35,7 @@ class RedisCacheLockTest extends LockTest
|
|||
{
|
||||
protected function getInstance()
|
||||
{
|
||||
$configMock = \Mockery::mock(IConfig::class);
|
||||
$configMock = Mockery::mock(IConfig::class);
|
||||
|
||||
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
|
||||
$port = $_SERVER['REDIS_PORT'] ?? null;
|
||||
|
@ -61,8 +63,8 @@ class RedisCacheLockTest extends LockTest
|
|||
try {
|
||||
$cache = new RedisCache($host, $configMock);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Redis is not available');
|
||||
} catch (Exception $e) {
|
||||
static::markTestSkipped('Redis is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
|
|
|
@ -27,20 +27,21 @@ use Friendica\Core\Config\IConfig;
|
|||
use Friendica\Core\Config\JitConfig;
|
||||
use Friendica\Core\Lock\SemaphoreLock;
|
||||
use Friendica\DI;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class SemaphoreLockTest extends LockTest
|
||||
{
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
/** @var MockInterface|Dice $dice */
|
||||
$dice = \Mockery::mock(Dice::class)->makePartial();
|
||||
$dice = Mockery::mock(Dice::class)->makePartial();
|
||||
|
||||
$app = \Mockery::mock(App::class);
|
||||
$app = Mockery::mock(App::class);
|
||||
$app->shouldReceive('getHostname')->andReturn('friendica.local');
|
||||
$dice->shouldReceive('create')->with(App::class)->andReturn($app);
|
||||
|
||||
$configMock = \Mockery::mock(JitConfig::class);
|
||||
$configMock = Mockery::mock(JitConfig::class);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'temppath')
|
||||
|
@ -58,7 +59,7 @@ class SemaphoreLockTest extends LockTest
|
|||
return new SemaphoreLock();
|
||||
}
|
||||
|
||||
function testLockTTL()
|
||||
public function testLockTTL()
|
||||
{
|
||||
// Semaphore doesn't work with TTL
|
||||
return true;
|
||||
|
@ -83,6 +84,7 @@ class SemaphoreLockTest extends LockTest
|
|||
* This test proves that semaphore locks cannot get released by other instances except themselves
|
||||
*
|
||||
* Check for Bug https://github.com/friendica/friendica/issues/7298#issuecomment-521996540
|
||||
*
|
||||
* @see https://github.com/friendica/friendica/issues/7298#issuecomment-521996540
|
||||
*/
|
||||
public function testMissingFileOverriding()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue