1
0
Fork 0

Fix a lot of notices/warnings/deprecation notes in the test directory

This commit is contained in:
Philipp Holzer 2020-10-18 20:31:57 +02:00
commit d55ecb9288
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
77 changed files with 428 additions and 558 deletions

View file

@ -31,7 +31,7 @@ class APCuCacheTest extends MemoryCacheTest
protected function setUp()
{
if (!APCuCache::isAvailable()) {
$this->markTestSkipped('APCu is not available');
static::markTestSkipped('APCu is not available');
}
parent::setUp();
@ -43,7 +43,7 @@ class APCuCacheTest extends MemoryCacheTest
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();

View file

@ -31,7 +31,7 @@ class ArrayCacheTest extends MemoryCacheTest
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();

View file

@ -21,6 +21,8 @@
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Test\MockedTest;
use Friendica\Util\PidFile;
@ -32,12 +34,12 @@ abstract class CacheTest extends MockedTest
protected $startTime = 1417011228;
/**
* @var \Friendica\Core\Cache\ICache
* @var ICache
*/
protected $instance;
/**
* @var \Friendica\Core\Cache\IMemoryCache
* @var IMemoryCache
*/
protected $cache;
@ -95,7 +97,7 @@ abstract class CacheTest extends MockedTest
* @param mixed $value1 a first
* @param mixed $value2 a second
*/
function testSimple($value1, $value2)
public function testSimple($value1, $value2)
{
self::assertNull($this->instance->get('value1'));
@ -127,9 +129,8 @@ abstract class CacheTest extends MockedTest
* @param mixed $value3 a third
* @param mixed $value4 a fourth
*/
function testClear($value1, $value2, $value3, $value4)
public function testClear($value1, $value2, $value3, $value4)
{
$value = 'ipsum lorum';
$this->instance->set('1_value1', $value1);
$this->instance->set('1_value2', $value2);
$this->instance->set('2_value1', $value3);
@ -179,9 +180,9 @@ abstract class CacheTest extends MockedTest
/**
* @medium
*/
function testTTL()
public function testTTL()
{
$this->markTestSkipped('taking too much time without mocking');
static::markTestSkipped('taking too much time without mocking');
self::assertNull($this->instance->get('value1'));
@ -198,11 +199,11 @@ abstract class CacheTest extends MockedTest
/**
* @small
*
* @param $data mixed the data to store in the cache
* @param mixed $data the data to store in the cache
*
* @dataProvider dataTypesInCache
*/
function testDifferentTypesInCache($data)
public function testDifferentTypesInCache($data)
{
$this->instance->set('val', $data);
$received = $this->instance->get('val');

View file

@ -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 DatabaseCacheTest extends CacheTest
@ -45,7 +46,7 @@ class DatabaseCacheTest extends CacheTest
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
@ -59,7 +60,7 @@ class DatabaseCacheTest extends CacheTest
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();

View file

@ -21,8 +21,10 @@
namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\MemcacheCache;
use Friendica\Core\Config\IConfig;
use Mockery;
/**
* @requires extension memcache
@ -32,7 +34,7 @@ class MemcacheCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHE_PORT'] ?? '11211';
@ -48,13 +50,13 @@ class MemcacheCacheTest extends MemoryCacheTest
try {
$this->cache = new MemcacheCache($host, $configMock);
} catch (\Exception $e) {
$this->markTestSkipped('Memcache is not available');
} catch (Exception $e) {
static::markTestSkipped('Memcache is not available');
}
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();
@ -67,6 +69,6 @@ class MemcacheCacheTest extends MemoryCacheTest
*/
public function testGetAllKeys($value1, $value2, $value3)
{
$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');
}
}

View file

@ -21,8 +21,10 @@
namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\MemcachedCache;
use Friendica\Core\Config\IConfig;
use Mockery;
use Psr\Log\NullLogger;
/**
@ -33,7 +35,7 @@ class MemcachedCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
$port = $_SERVER['MEMCACHED_PORT'] ?? '11211';
@ -47,13 +49,13 @@ class MemcachedCacheTest extends MemoryCacheTest
try {
$this->cache = new MemcachedCache($host, $configMock, $logger);
} catch (\Exception $exception) {
$this->markTestSkipped('Memcached is not available');
} catch (Exception $exception) {
static::markTestSkipped('Memcached is not available');
}
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();
@ -66,6 +68,6 @@ class MemcachedCacheTest extends MemoryCacheTest
*/
public function testGetAllKeys($value1, $value2, $value3)
{
$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');
}
}

View file

@ -21,12 +21,13 @@
namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\IMemoryCache;
abstract class MemoryCacheTest extends CacheTest
{
/**
* @var \Friendica\Core\Cache\IMemoryCache
* @var IMemoryCache
*/
protected $instance;
@ -35,7 +36,7 @@ abstract class MemoryCacheTest extends CacheTest
parent::setUp();
if (!($this->instance instanceof IMemoryCache)) {
throw new \Exception('MemoryCacheTest unsupported');
throw new Exception('MemoryCacheTest unsupported');
}
}
@ -43,7 +44,7 @@ abstract class MemoryCacheTest extends CacheTest
* @small
* @dataProvider dataSimple
*/
function testCompareSet($value1, $value2)
public function testCompareSet($value1, $value2)
{
self::assertNull($this->instance->get('value1'));
@ -60,7 +61,7 @@ abstract class MemoryCacheTest extends CacheTest
* @small
* @dataProvider dataSimple
*/
function testNegativeCompareSet($value1, $value2)
public function testNegativeCompareSet($value1, $value2)
{
self::assertNull($this->instance->get('value1'));
@ -78,7 +79,7 @@ abstract class MemoryCacheTest extends CacheTest
* @small
* @dataProvider dataSimple
*/
function testCompareDelete($data)
public function testCompareDelete($data)
{
self::assertNull($this->instance->get('value1'));
@ -93,7 +94,7 @@ abstract class MemoryCacheTest extends CacheTest
* @small
* @dataProvider dataSimple
*/
function testNegativeCompareDelete($data)
public function testNegativeCompareDelete($data)
{
self::assertNull($this->instance->get('value1'));
@ -111,7 +112,7 @@ abstract class MemoryCacheTest extends CacheTest
* @small
* @dataProvider dataSimple
*/
function testAdd($value1, $value2)
public function testAdd($value1, $value2)
{
self::assertNull($this->instance->get('value1'));

View file

@ -21,8 +21,10 @@
namespace Friendica\Test\src\Core\Cache;
use Exception;
use Friendica\Core\Cache\RedisCache;
use Friendica\Core\Config\IConfig;
use Mockery;
/**
* @requires extension redis
@ -32,7 +34,7 @@ class RedisCacheTest extends MemoryCacheTest
{
protected function getInstance()
{
$configMock = \Mockery::mock(IConfig::class);
$configMock = Mockery::mock(IConfig::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
$port = $_SERVER['REDIS_PORT'] ?? null;
@ -57,13 +59,13 @@ class RedisCacheTest extends MemoryCacheTest
try {
$this->cache = new RedisCache($host, $configMock);
} catch (\Exception $e) {
$this->markTestSkipped('Redis is not available.');
} catch (Exception $e) {
static::markTestSkipped('Redis is not available.');
}
return $this->cache;
}
public function tearDown()
protected function tearDown()
{
$this->cache->clear(false);
parent::tearDown();