From 7b39b3b9c07c92e1713c29c0cbeac3f4ca9954ba Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 27 Apr 2025 02:08:01 +0200 Subject: [PATCH] Mak PHPCS happy --- tests/LockTestCase.php | 3 -- tests/src/Core/Lock/APCuCacheLockTest.php | 2 +- tests/src/Core/Lock/ArrayCacheLockTest.php | 2 +- tests/src/Core/Lock/MemcacheCacheLockTest.php | 2 +- .../src/Core/Lock/MemcachedCacheLockTest.php | 3 +- tests/src/Core/Lock/RedisCacheLockTest.php | 3 +- tests/src/Core/Lock/SemaphoreLockTest.php | 2 +- tests/src/Module/StatsCachingTest.php | 38 +++++++++---------- 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/tests/LockTestCase.php b/tests/LockTestCase.php index 1b80e575ef7..92abf0ca7b7 100644 --- a/tests/LockTestCase.php +++ b/tests/LockTestCase.php @@ -7,10 +7,7 @@ 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\Type\CacheLock; abstract class LockTestCase extends MockedTestCase { diff --git a/tests/src/Core/Lock/APCuCacheLockTest.php b/tests/src/Core/Lock/APCuCacheLockTest.php index 42a1fc72d53..3b6c7904b43 100644 --- a/tests/src/Core/Lock/APCuCacheLockTest.php +++ b/tests/src/Core/Lock/APCuCacheLockTest.php @@ -28,7 +28,7 @@ class APCuCacheLockTest extends CacheLockTestCase } $this->cache = new APCuCache('localhost'); - $this->lock = new CacheLock($this->cache); + $this->lock = new CacheLock($this->cache); parent::setUp(); } diff --git a/tests/src/Core/Lock/ArrayCacheLockTest.php b/tests/src/Core/Lock/ArrayCacheLockTest.php index 2aac8e82933..07cd88dd1cf 100644 --- a/tests/src/Core/Lock/ArrayCacheLockTest.php +++ b/tests/src/Core/Lock/ArrayCacheLockTest.php @@ -20,7 +20,7 @@ class ArrayCacheLockTest extends CacheLockTestCase protected function setUp(): void { $this->cache = new ArrayCache('localhost'); - $this->lock = new CacheLock($this->cache); + $this->lock = new CacheLock($this->cache); parent::setUp(); } diff --git a/tests/src/Core/Lock/MemcacheCacheLockTest.php b/tests/src/Core/Lock/MemcacheCacheLockTest.php index c1dec663f11..8915e6d37cf 100644 --- a/tests/src/Core/Lock/MemcacheCacheLockTest.php +++ b/tests/src/Core/Lock/MemcacheCacheLockTest.php @@ -42,7 +42,7 @@ class MemcacheCacheLockTest extends CacheLockTestCase try { $this->cache = new MemcacheCache($host, $configMock); - $this->lock = new CacheLock($this->cache); + $this->lock = new CacheLock($this->cache); } catch (Exception $e) { static::markTestSkipped('Memcache is not available'); } diff --git a/tests/src/Core/Lock/MemcachedCacheLockTest.php b/tests/src/Core/Lock/MemcachedCacheLockTest.php index 773e6641085..522f60c64a9 100644 --- a/tests/src/Core/Lock/MemcachedCacheLockTest.php +++ b/tests/src/Core/Lock/MemcachedCacheLockTest.php @@ -13,7 +13,6 @@ use Friendica\Core\Cache\Type\MemcachedCache; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Lock\Type\CacheLock; use Friendica\Test\CacheLockTestCase; -use Friendica\Test\LockTestCase; use Mockery; use Psr\Log\NullLogger; @@ -42,7 +41,7 @@ class MemcachedCacheLockTest extends CacheLockTestCase try { $this->cache = new MemcachedCache($host, $configMock, $logger); - $this->lock = new CacheLock($this->cache); + $this->lock = new CacheLock($this->cache); } catch (Exception $e) { static::markTestSkipped('Memcached is not available'); } diff --git a/tests/src/Core/Lock/RedisCacheLockTest.php b/tests/src/Core/Lock/RedisCacheLockTest.php index 3cb4fba4368..1136b80c4b9 100644 --- a/tests/src/Core/Lock/RedisCacheLockTest.php +++ b/tests/src/Core/Lock/RedisCacheLockTest.php @@ -13,7 +13,6 @@ use Friendica\Core\Cache\Type\RedisCache; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Lock\Type\CacheLock; use Friendica\Test\CacheLockTestCase; -use Friendica\Test\LockTestCase; use Mockery; /** @@ -49,7 +48,7 @@ class RedisCacheLockTest extends CacheLockTestCase try { $this->cache = new RedisCache($host, $configMock); - $this->lock = new CacheLock($this->cache); + $this->lock = new CacheLock($this->cache); } catch (Exception $e) { static::markTestSkipped('Redis is not available. Error: ' . $e->getMessage()); } diff --git a/tests/src/Core/Lock/SemaphoreLockTest.php b/tests/src/Core/Lock/SemaphoreLockTest.php index 1ddb2dade75..30152ac4277 100644 --- a/tests/src/Core/Lock/SemaphoreLockTest.php +++ b/tests/src/Core/Lock/SemaphoreLockTest.php @@ -32,7 +32,7 @@ class SemaphoreLockTest extends LockTestCase $dice->shouldReceive('create')->with(App::class)->andReturn($app); $configCache = new Cache(['system' => ['temppath' => '/tmp']]); - $configMock = new ReadOnlyFileConfig($configCache); + $configMock = new ReadOnlyFileConfig($configCache); $dice->shouldReceive('create')->with(IManageConfigValues::class)->andReturn($configMock); // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject diff --git a/tests/src/Module/StatsCachingTest.php b/tests/src/Module/StatsCachingTest.php index 78554929e2a..58226769a95 100644 --- a/tests/src/Module/StatsCachingTest.php +++ b/tests/src/Module/StatsCachingTest.php @@ -38,9 +38,9 @@ class StatsCachingTest extends FixtureTestCase parent::setUp(); $this->httpExceptionMock = \Mockery::mock(HTTPException::class); - $this->config = \Mockery::mock(IManageConfigValues::class); - $this->cache = new ArrayCache('localhost'); - $this->lock = new CacheLock($this->cache); + $this->config = \Mockery::mock(IManageConfigValues::class); + $this->cache = new ArrayCache('localhost'); + $this->lock = new CacheLock($this->cache); } public function testStatsCachingNotAllowed() @@ -72,11 +72,11 @@ class StatsCachingTest extends FixtureTestCase $json = json_decode($response->getBody(), true); self::assertEquals([ - 'type' => 'array', + 'type' => 'array', 'stats' => [], ], $json['cache']); self::assertEquals([ - 'type' => 'array', + 'type' => 'array', 'stats' => [], ], $json['lock']); } @@ -89,7 +89,7 @@ class StatsCachingTest extends FixtureTestCase $this->config->shouldReceive('get')->with('system', 'stats_key')->twice()->andReturn('12345'); $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); $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->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); $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->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", "opcache_get_status")->with(false)->once()->andReturn(false); @@ -150,10 +150,10 @@ class StatsCachingTest extends FixtureTestCase $json = json_decode($response->getBody(), true); self::assertEquals([ - 'enabled' => false, - 'hit_rate' => null, - 'used_memory' => null, - 'free_memory' => null, + 'enabled' => false, + 'hit_rate' => null, + 'used_memory' => null, + 'free_memory' => null, 'num_cached_scripts' => null, ], $json['opcache']); 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->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", "opcache_get_status")->with(false)->once()->andReturn([ - 'opcache_enabled' => true, + 'opcache_enabled' => true, 'opcache_statistics' => [ - 'opcache_hit_rate' => 1, + 'opcache_hit_rate' => 1, 'num_cached_scripts' => 2, ], 'memory_usage' => [ @@ -191,10 +191,10 @@ class StatsCachingTest extends FixtureTestCase $json = json_decode($response->getBody(), true); self::assertEquals([ - 'enabled' => true, - 'hit_rate' => 1, - 'used_memory' => 3, - 'free_memory' => 4, + 'enabled' => true, + 'hit_rate' => 1, + 'used_memory' => 3, + 'free_memory' => 4, 'num_cached_scripts' => 2, ], $json['opcache']); self::assertEquals(['type' => 'database'], $json['cache']);