Mak PHPCS happy

This commit is contained in:
Philipp 2025-04-27 02:08:01 +02:00
parent 03cfa2d066
commit 7b39b3b9c0
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
8 changed files with 25 additions and 30 deletions

View file

@ -7,10 +7,7 @@
namespace Friendica\Test; namespace Friendica\Test;
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Cache\Capability\ICanCacheInMemory;
use Friendica\Core\Lock\Capability\ICanLock; use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\Core\Lock\Type\CacheLock;
abstract class LockTestCase extends MockedTestCase abstract class LockTestCase extends MockedTestCase
{ {

View file

@ -28,7 +28,7 @@ class APCuCacheLockTest extends CacheLockTestCase
} }
$this->cache = new APCuCache('localhost'); $this->cache = new APCuCache('localhost');
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
parent::setUp(); parent::setUp();
} }

View file

@ -20,7 +20,7 @@ class ArrayCacheLockTest extends CacheLockTestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->cache = new ArrayCache('localhost'); $this->cache = new ArrayCache('localhost');
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
parent::setUp(); parent::setUp();
} }

View file

@ -42,7 +42,7 @@ class MemcacheCacheLockTest extends CacheLockTestCase
try { try {
$this->cache = new MemcacheCache($host, $configMock); $this->cache = new MemcacheCache($host, $configMock);
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
} catch (Exception $e) { } catch (Exception $e) {
static::markTestSkipped('Memcache is not available'); static::markTestSkipped('Memcache is not available');
} }

View file

@ -13,7 +13,6 @@ use Friendica\Core\Cache\Type\MemcachedCache;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Lock\Type\CacheLock; use Friendica\Core\Lock\Type\CacheLock;
use Friendica\Test\CacheLockTestCase; use Friendica\Test\CacheLockTestCase;
use Friendica\Test\LockTestCase;
use Mockery; use Mockery;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
@ -42,7 +41,7 @@ class MemcachedCacheLockTest extends CacheLockTestCase
try { try {
$this->cache = new MemcachedCache($host, $configMock, $logger); $this->cache = new MemcachedCache($host, $configMock, $logger);
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
} catch (Exception $e) { } catch (Exception $e) {
static::markTestSkipped('Memcached is not available'); static::markTestSkipped('Memcached is not available');
} }

View file

@ -13,7 +13,6 @@ use Friendica\Core\Cache\Type\RedisCache;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Lock\Type\CacheLock; use Friendica\Core\Lock\Type\CacheLock;
use Friendica\Test\CacheLockTestCase; use Friendica\Test\CacheLockTestCase;
use Friendica\Test\LockTestCase;
use Mockery; use Mockery;
/** /**
@ -49,7 +48,7 @@ class RedisCacheLockTest extends CacheLockTestCase
try { try {
$this->cache = new RedisCache($host, $configMock); $this->cache = new RedisCache($host, $configMock);
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
} catch (Exception $e) { } catch (Exception $e) {
static::markTestSkipped('Redis is not available. Error: ' . $e->getMessage()); static::markTestSkipped('Redis is not available. Error: ' . $e->getMessage());
} }

View file

@ -32,7 +32,7 @@ class SemaphoreLockTest extends LockTestCase
$dice->shouldReceive('create')->with(App::class)->andReturn($app); $dice->shouldReceive('create')->with(App::class)->andReturn($app);
$configCache = new Cache(['system' => ['temppath' => '/tmp']]); $configCache = new Cache(['system' => ['temppath' => '/tmp']]);
$configMock = new ReadOnlyFileConfig($configCache); $configMock = new ReadOnlyFileConfig($configCache);
$dice->shouldReceive('create')->with(IManageConfigValues::class)->andReturn($configMock); $dice->shouldReceive('create')->with(IManageConfigValues::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject

View file

@ -38,9 +38,9 @@ class StatsCachingTest extends FixtureTestCase
parent::setUp(); parent::setUp();
$this->httpExceptionMock = \Mockery::mock(HTTPException::class); $this->httpExceptionMock = \Mockery::mock(HTTPException::class);
$this->config = \Mockery::mock(IManageConfigValues::class); $this->config = \Mockery::mock(IManageConfigValues::class);
$this->cache = new ArrayCache('localhost'); $this->cache = new ArrayCache('localhost');
$this->lock = new CacheLock($this->cache); $this->lock = new CacheLock($this->cache);
} }
public function testStatsCachingNotAllowed() public function testStatsCachingNotAllowed()
@ -72,11 +72,11 @@ class StatsCachingTest extends FixtureTestCase
$json = json_decode($response->getBody(), true); $json = json_decode($response->getBody(), true);
self::assertEquals([ self::assertEquals([
'type' => 'array', 'type' => 'array',
'stats' => [], 'stats' => [],
], $json['cache']); ], $json['cache']);
self::assertEquals([ self::assertEquals([
'type' => 'array', 'type' => 'array',
'stats' => [], 'stats' => [],
], $json['lock']); ], $json['lock']);
} }
@ -89,7 +89,7 @@ class StatsCachingTest extends FixtureTestCase
$this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345'); $this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345');
$this->cache = new DatabaseCache('localhost', DI::dba()); $this->cache = new DatabaseCache('localhost', DI::dba());
$this->lock = new DatabaseLock(DI::dba()); $this->lock = new DatabaseLock(DI::dba());
PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(false); PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(false);
$response = (new StatsCaching(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], $this->config, $this->cache, $this->lock, [])) $response = (new StatsCaching(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], $this->config, $this->cache, $this->lock, []))
@ -113,7 +113,7 @@ class StatsCachingTest extends FixtureTestCase
$this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345'); $this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345');
$this->cache = new DatabaseCache('localhost', DI::dba()); $this->cache = new DatabaseCache('localhost', DI::dba());
$this->lock = new DatabaseLock(DI::dba()); $this->lock = new DatabaseLock(DI::dba());
PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(false); PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(false);
$response = (new StatsCaching(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], $this->config, $this->cache, $this->lock, [])) $response = (new StatsCaching(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], $this->config, $this->cache, $this->lock, []))
@ -137,7 +137,7 @@ class StatsCachingTest extends FixtureTestCase
$this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345'); $this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345');
$this->cache = new DatabaseCache('localhost', DI::dba()); $this->cache = new DatabaseCache('localhost', DI::dba());
$this->lock = new DatabaseLock(DI::dba()); $this->lock = new DatabaseLock(DI::dba());
PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(true); PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(true);
PHPMockery::mock("Friendica\\Module", "opcache_get_status")->with(false)->once()->andReturn(false); PHPMockery::mock("Friendica\\Module", "opcache_get_status")->with(false)->once()->andReturn(false);
@ -150,10 +150,10 @@ class StatsCachingTest extends FixtureTestCase
$json = json_decode($response->getBody(), true); $json = json_decode($response->getBody(), true);
self::assertEquals([ self::assertEquals([
'enabled' => false, 'enabled' => false,
'hit_rate' => null, 'hit_rate' => null,
'used_memory' => null, 'used_memory' => null,
'free_memory' => null, 'free_memory' => null,
'num_cached_scripts' => null, 'num_cached_scripts' => null,
], $json['opcache']); ], $json['opcache']);
self::assertEquals(['type' => 'database'], $json['cache']); self::assertEquals(['type' => 'database'], $json['cache']);
@ -168,12 +168,12 @@ class StatsCachingTest extends FixtureTestCase
$this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345'); $this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345');
$this->cache = new DatabaseCache('localhost', DI::dba()); $this->cache = new DatabaseCache('localhost', DI::dba());
$this->lock = new DatabaseLock(DI::dba()); $this->lock = new DatabaseLock(DI::dba());
PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(true); PHPMockery::mock("Friendica\\Module", "function_exists")->with('opcache_get_status')->once()->andReturn(true);
PHPMockery::mock("Friendica\\Module", "opcache_get_status")->with(false)->once()->andReturn([ PHPMockery::mock("Friendica\\Module", "opcache_get_status")->with(false)->once()->andReturn([
'opcache_enabled' => true, 'opcache_enabled' => true,
'opcache_statistics' => [ 'opcache_statistics' => [
'opcache_hit_rate' => 1, 'opcache_hit_rate' => 1,
'num_cached_scripts' => 2, 'num_cached_scripts' => 2,
], ],
'memory_usage' => [ 'memory_usage' => [
@ -191,10 +191,10 @@ class StatsCachingTest extends FixtureTestCase
$json = json_decode($response->getBody(), true); $json = json_decode($response->getBody(), true);
self::assertEquals([ self::assertEquals([
'enabled' => true, 'enabled' => true,
'hit_rate' => 1, 'hit_rate' => 1,
'used_memory' => 3, 'used_memory' => 3,
'free_memory' => 4, 'free_memory' => 4,
'num_cached_scripts' => 2, 'num_cached_scripts' => 2,
], $json['opcache']); ], $json['opcache']);
self::assertEquals(['type' => 'database'], $json['cache']); self::assertEquals(['type' => 'database'], $json['cache']);