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
|
@ -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();
|
||||
|
|
|
@ -31,7 +31,7 @@ class ArrayCacheTest extends MemoryCacheTest
|
|||
return $this->cache;
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->cache->clear(false);
|
||||
parent::tearDown();
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Test\src\Core\Config;
|
|||
use Friendica\Core\Config\Cache;
|
||||
use Friendica\Test\MockedTest;
|
||||
use ParagonIE\HiddenString\HiddenString;
|
||||
use stdClass;
|
||||
|
||||
class CacheTest extends MockedTest
|
||||
{
|
||||
|
@ -300,7 +301,7 @@ class CacheTest extends MockedTest
|
|||
{
|
||||
$configCache = new Cache([
|
||||
'database' => [
|
||||
'password' => new \stdClass(),
|
||||
'password' => new stdClass(),
|
||||
'username' => '',
|
||||
]
|
||||
]);
|
||||
|
|
|
@ -67,7 +67,7 @@ abstract class ConfigTest extends MockedTest
|
|||
/**
|
||||
* @return IConfig
|
||||
*/
|
||||
public abstract function getInstance();
|
||||
abstract public function getInstance();
|
||||
|
||||
public function dataTests()
|
||||
{
|
||||
|
@ -169,8 +169,11 @@ abstract class ConfigTest extends MockedTest
|
|||
|
||||
/**
|
||||
* Test the configuration load() method
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*/
|
||||
public function testLoad(array $data, array $possibleCats, array $load)
|
||||
public function testLoad(array $data, array $load)
|
||||
{
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
@ -251,7 +254,7 @@ abstract class ConfigTest extends MockedTest
|
|||
/**
|
||||
* Test the configuration load() method with overwrite
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect)
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
|
|
@ -45,8 +45,11 @@ class JitConfigTest extends ConfigTest
|
|||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*/
|
||||
public function testLoad(array $data, array $possibleCats, array $load)
|
||||
public function testLoad(array $data, array $load)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
|
@ -64,13 +67,13 @@ class JitConfigTest extends ConfigTest
|
|||
->once();
|
||||
}
|
||||
|
||||
parent::testLoad($data, $possibleCats, $load);
|
||||
parent::testLoad($data, $load);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataDoubleLoad
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect)
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
|
@ -96,7 +99,7 @@ class JitConfigTest extends ConfigTest
|
|||
->once();
|
||||
}
|
||||
|
||||
parent::testCacheLoadDouble($data1, $data2, $expect);
|
||||
parent::testCacheLoadDouble($data1, $data2);
|
||||
|
||||
// Assert the expected categories
|
||||
foreach ($data2 as $cat => $data) {
|
||||
|
|
|
@ -44,8 +44,11 @@ class PreloadConfigTest extends ConfigTest
|
|||
|
||||
/**
|
||||
* @dataProvider dataConfigLoad
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $load
|
||||
*/
|
||||
public function testLoad(array $data, array $possibleCats, array $load)
|
||||
public function testLoad(array $data, array $load)
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
|
@ -55,7 +58,7 @@ class PreloadConfigTest extends ConfigTest
|
|||
->andReturn($data)
|
||||
->once();
|
||||
|
||||
parent::testLoad($data, $possibleCats, $load);
|
||||
parent::testLoad($data, $load);
|
||||
|
||||
// Assert that every category is loaded everytime
|
||||
foreach ($data as $cat => $values) {
|
||||
|
@ -65,8 +68,11 @@ class PreloadConfigTest extends ConfigTest
|
|||
|
||||
/**
|
||||
* @dataProvider dataDoubleLoad
|
||||
*
|
||||
* @param array $data1
|
||||
* @param array $data2
|
||||
*/
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect)
|
||||
public function testCacheLoadDouble(array $data1, array $data2, array $expect = [])
|
||||
{
|
||||
$this->configModel->shouldReceive('isConnected')
|
||||
->andReturn(true)
|
||||
|
@ -76,7 +82,7 @@ class PreloadConfigTest extends ConfigTest
|
|||
->andReturn($data1)
|
||||
->once();
|
||||
|
||||
parent::testCacheLoadDouble($data1, $data2, $expect);
|
||||
parent::testCacheLoadDouble($data1, $data2);
|
||||
|
||||
// Assert that every category is loaded everytime and is NOT overwritten
|
||||
foreach ($data1 as $cat => $values) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
// this is in the same namespace as Install for mocking 'function_exists'
|
||||
/// @todo this is in the same namespace as Install for mocking 'function_exists'
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Dice\Dice;
|
||||
|
@ -29,6 +29,7 @@ use Friendica\Network\CurlResult;
|
|||
use Friendica\Network\IHTTPRequest;
|
||||
use Friendica\Test\MockedTest;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class InstallerTest extends MockedTest
|
||||
|
@ -36,7 +37,7 @@ class InstallerTest extends MockedTest
|
|||
use VFSTrait;
|
||||
|
||||
/**
|
||||
* @var \Friendica\Core\L10n|MockInterface
|
||||
* @var L10n|MockInterface
|
||||
*/
|
||||
private $l10nMock;
|
||||
/**
|
||||
|
@ -44,20 +45,20 @@ class InstallerTest extends MockedTest
|
|||
*/
|
||||
private $dice;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpVfsDir();
|
||||
|
||||
$this->l10nMock = \Mockery::mock(\Friendica\Core\L10n::class);
|
||||
$this->l10nMock = Mockery::mock(L10n::class);
|
||||
|
||||
/** @var Dice|MockInterface $dice */
|
||||
$this->dice = \Mockery::mock(Dice::class)->makePartial();
|
||||
$this->dice = Mockery::mock(Dice::class)->makePartial();
|
||||
$this->dice = $this->dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
|
||||
|
||||
$this->dice->shouldReceive('create')
|
||||
->with(\Friendica\Core\L10n::class)
|
||||
->with(L10n::class)
|
||||
->andReturn($this->l10nMock);
|
||||
|
||||
DI::init($this->dice);
|
||||
|
@ -112,7 +113,7 @@ class InstallerTest extends MockedTest
|
|||
*
|
||||
* @param array $functions a list from function names and their result
|
||||
*/
|
||||
private function setFunctions($functions)
|
||||
private function setFunctions(array $functions)
|
||||
{
|
||||
global $phpMock;
|
||||
$phpMock['function_exists'] = function($function) use ($functions) {
|
||||
|
@ -130,7 +131,7 @@ class InstallerTest extends MockedTest
|
|||
*
|
||||
* @param array $classes a list from class names and their results
|
||||
*/
|
||||
private function setClasses($classes)
|
||||
private function setClasses(array $classes)
|
||||
{
|
||||
global $phpMock;
|
||||
$phpMock['class_exists'] = function($class) use ($classes) {
|
||||
|
@ -297,7 +298,7 @@ class InstallerTest extends MockedTest
|
|||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
// Mocking the CURL Response
|
||||
$curlResult = \Mockery::mock(CurlResult::class);
|
||||
$curlResult = Mockery::mock(CurlResult::class);
|
||||
$curlResult
|
||||
->shouldReceive('getReturnCode')
|
||||
->andReturn('404');
|
||||
|
@ -309,7 +310,7 @@ class InstallerTest extends MockedTest
|
|||
->andReturn('test Error');
|
||||
|
||||
// Mocking the CURL Request
|
||||
$networkMock = \Mockery::mock(IHTTPRequest::class);
|
||||
$networkMock = Mockery::mock(IHTTPRequest::class);
|
||||
$networkMock
|
||||
->shouldReceive('fetchFull')
|
||||
->with('https://test/install/testrewrite')
|
||||
|
@ -344,19 +345,19 @@ class InstallerTest extends MockedTest
|
|||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
// Mocking the failed CURL Response
|
||||
$curlResultF = \Mockery::mock(CurlResult::class);
|
||||
$curlResultF = Mockery::mock(CurlResult::class);
|
||||
$curlResultF
|
||||
->shouldReceive('getReturnCode')
|
||||
->andReturn('404');
|
||||
|
||||
// Mocking the working CURL Response
|
||||
$curlResultW = \Mockery::mock(CurlResult::class);
|
||||
$curlResultW = Mockery::mock(CurlResult::class);
|
||||
$curlResultW
|
||||
->shouldReceive('getReturnCode')
|
||||
->andReturn('204');
|
||||
|
||||
// Mocking the CURL Request
|
||||
$networkMock = \Mockery::mock(IHTTPRequest::class);
|
||||
$networkMock = Mockery::mock(IHTTPRequest::class);
|
||||
$networkMock
|
||||
->shouldReceive('fetchFull')
|
||||
->with('https://test/install/testrewrite')
|
||||
|
@ -387,7 +388,7 @@ class InstallerTest extends MockedTest
|
|||
*/
|
||||
public function testImagick()
|
||||
{
|
||||
$this->markTestIncomplete('needs adapted class_exists() mock');
|
||||
static::markTestIncomplete('needs adapted class_exists() mock');
|
||||
|
||||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
|
@ -413,7 +414,7 @@ class InstallerTest extends MockedTest
|
|||
*/
|
||||
public function testImagickNotFound()
|
||||
{
|
||||
$this->markTestIncomplete('Disabled due not working/difficult mocking global functions - needs more care!');
|
||||
static::markTestIncomplete('Disabled due not working/difficult mocking global functions - needs more care!');
|
||||
|
||||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
|
@ -456,8 +457,8 @@ class InstallerTest extends MockedTest
|
|||
$this->l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
$install = new Installer();
|
||||
$configCache = \Mockery::mock(Cache::class);
|
||||
$configCache->shouldReceive('set')->with('config', 'php_path', \Mockery::any())->once();
|
||||
$configCache = Mockery::mock(Cache::class);
|
||||
$configCache->shouldReceive('set')->with('config', 'php_path', Mockery::any())->once();
|
||||
$configCache->shouldReceive('set')->with('system', 'basepath', '/test/')->once();
|
||||
|
||||
$install->setUpCache($configCache, '/test/');
|
||||
|
@ -471,7 +472,7 @@ class InstallerTest extends MockedTest
|
|||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
function function_exists($function_name)
|
||||
function function_exists(string $function_name)
|
||||
{
|
||||
global $phpMock;
|
||||
if (isset($phpMock['function_exists'])) {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -133,10 +133,8 @@ class CacheTest extends MockedTest
|
|||
|
||||
/**
|
||||
* Test the keyDiff() method with result
|
||||
*
|
||||
* @dataProvider dataTests
|
||||
*/
|
||||
public function testKeyDiffWithResult($data)
|
||||
public function testKeyDiffWithResult()
|
||||
{
|
||||
$configCache = new Cache();
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Test\src\Core\PConfig;
|
||||
|
||||
use Friendica\Core\PConfig\JitPConfig;
|
||||
use Friendica\Test\src\Core\PConfig\PConfigTest;
|
||||
|
||||
class JitPConfigTest extends PConfigTest
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class PConfigTest extends MockedTest
|
|||
/**
|
||||
* @return BasePConfig
|
||||
*/
|
||||
public abstract function getInstance();
|
||||
abstract public function getInstance();
|
||||
|
||||
public function dataTests()
|
||||
{
|
||||
|
@ -159,9 +159,8 @@ abstract class PConfigTest extends MockedTest
|
|||
|
||||
/**
|
||||
* Test the configuration initialization
|
||||
* @dataProvider dataConfigLoad
|
||||
*/
|
||||
public function testSetUp(int $uid, array $data)
|
||||
public function testSetUp()
|
||||
{
|
||||
$this->testedConfig = $this->getInstance();
|
||||
self::assertInstanceOf(Cache::class, $this->testedConfig->getCache());
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Test\src\Core\PConfig;
|
||||
|
||||
use Friendica\Core\PConfig\PreloadPConfig;
|
||||
use Friendica\Test\src\Core\PConfig\PConfigTest;
|
||||
|
||||
class PreloadPConfigTest extends PConfigTest
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ use Friendica\Factory\ConfigFactory;
|
|||
use Friendica\Model\Config\Config;
|
||||
use Friendica\Model\Storage;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Model\Storage\StorageException;
|
||||
use Friendica\Test\DatabaseTest;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
|
@ -56,7 +57,7 @@ class StorageManagerTest extends DatabaseTest
|
|||
|
||||
use VFSTrait;
|
||||
|
||||
public function setUp()
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -319,12 +320,12 @@ class StorageManagerTest extends DatabaseTest
|
|||
|
||||
/**
|
||||
* Test moving data to a WRONG storage
|
||||
*
|
||||
* @expectedException \Friendica\Model\Storage\StorageException
|
||||
* @expectedExceptionMessage Can't move to storage backend 'SystemResource'
|
||||
*/
|
||||
public function testMoveStorageWrong()
|
||||
{
|
||||
$this->expectExceptionMessage("Can't move to storage backend 'SystemResource'");
|
||||
$this->expectException(StorageException::class);
|
||||
|
||||
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
|
||||
$storage = $storageManager->getByName(Storage\SystemResource::getName());
|
||||
$storageManager->move($storage);
|
||||
|
|
|
@ -45,28 +45,28 @@ class SystemTest extends TestCase
|
|||
self::assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
|
||||
}
|
||||
|
||||
function testGuidWithoutParameter()
|
||||
public function testGuidWithoutParameter()
|
||||
{
|
||||
$this->useBaseUrl();
|
||||
$guid = System::createGUID();
|
||||
self::assertGuid($guid, 16);
|
||||
}
|
||||
|
||||
function testGuidWithSize32()
|
||||
public function testGuidWithSize32()
|
||||
{
|
||||
$this->useBaseUrl();
|
||||
$guid = System::createGUID(32);
|
||||
self::assertGuid($guid, 32);
|
||||
}
|
||||
|
||||
function testGuidWithSize64()
|
||||
public function testGuidWithSize64()
|
||||
{
|
||||
$this->useBaseUrl();
|
||||
$guid = System::createGUID(64);
|
||||
self::assertGuid($guid, 64);
|
||||
}
|
||||
|
||||
function testGuidWithPrefix()
|
||||
public function testGuidWithPrefix()
|
||||
{
|
||||
$guid = System::createGUID(23, 'test');
|
||||
self::assertGuid($guid, 23, 'test');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue