Fix Cache tests
authorPhilipp <admin@philipp.info>
Wed, 19 Aug 2020 12:09:16 +0000 (14:09 +0200)
committerPhilipp <admin@philipp.info>
Wed, 19 Aug 2020 12:20:07 +0000 (14:20 +0200)
.github/workflows/php.yml
tests/src/Core/Cache/MemcacheCacheTest.php
tests/src/Core/Cache/MemcachedCacheTest.php
tests/src/Core/Cache/RedisCacheTest.php
tests/src/Core/Lock/MemcacheCacheLockTest.php
tests/src/Core/Lock/MemcachedCacheLockTest.php
tests/src/Core/Lock/RedisCacheLockTest.php

index c905ee8..eabd28f 100644 (file)
@@ -38,7 +38,7 @@ jobs:
         with:
           php-version: ${{ matrix.php-versions }}
           tools: pecl
-          extensions: pdo_mysql, gd, zip, opcache, ctype, pcntl, ldap, apcu, memcached, redis, imagick
+          extensions: pdo_mysql, gd, zip, opcache, ctype, pcntl, ldap, apcu, memcached, redis, imagick, memcache
           coverage: xdebug
           ini-values: apc.enabled=1, apc.enable_cli=1
 
@@ -90,6 +90,9 @@ jobs:
           MYSQL_DATABASE: test
           MYSQL_PASSWORD: test
           MYSQL_USER: test
+          REDIS_PORT: ${{ job.services.redis.ports[6379] }}
+          MEMCACHED_PORT: ${{ job.services.memcached.ports[11211] }}
+          MEMCACHE_PORT: ${{ job.services.memcached.ports[11211] }}
 
       - name: Upload coverage to Codecov
         uses: codecov/codecov-action@v1
index ed69d88..44600d5 100644 (file)
@@ -35,6 +35,7 @@ class MemcacheCacheTest extends MemoryCacheTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
+               $port = $_SERVER['MEMCACHE_PORT'] ?? '11211';
 
                $configMock
                        ->shouldReceive('get')
@@ -43,7 +44,7 @@ class MemcacheCacheTest extends MemoryCacheTest
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'memcache_port')
-                       ->andReturn(11211);
+                       ->andReturn($port);
 
                try {
                        $this->cache = new MemcacheCache($host, $configMock);
index 5fe96dd..c6ec48a 100644 (file)
@@ -36,11 +36,12 @@ class MemcachedCacheTest extends MemoryCacheTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
+               $port = $_SERVER['MEMCACHED_PORT'] ?? '11211';
 
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'memcached_hosts')
-                       ->andReturn([0 => $host . ', 11211']);
+                       ->andReturn([0 => $host . ', ' . $port]);
 
                $logger = new NullLogger();
 
index 821c3c5..543137c 100644 (file)
@@ -35,6 +35,7 @@ class RedisCacheTest extends MemoryCacheTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
+               $port = $_SERVER['REDIS_PORT'] ?? null;
 
                $configMock
                        ->shouldReceive('get')
@@ -43,7 +44,7 @@ class RedisCacheTest extends MemoryCacheTest
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'redis_port')
-                       ->andReturn(null);
+                       ->andReturn($port);
 
                $configMock
                        ->shouldReceive('get')
index 8008cb0..f4aab06 100644 (file)
@@ -36,6 +36,7 @@ class MemcacheCacheLockTest extends LockTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
+               $port = $_SERVER['MEMCACHE_PORT'] ?? '11211';
 
                $configMock
                        ->shouldReceive('get')
@@ -44,7 +45,7 @@ class MemcacheCacheLockTest extends LockTest
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'memcache_port')
-                       ->andReturn(11211);
+                       ->andReturn($port);
 
                $lock = null;
 
index 232f787..f41bf99 100644 (file)
@@ -37,11 +37,12 @@ class MemcachedCacheLockTest extends LockTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
+               $port = $_SERVER['MEMCACHED_PORT'] ?? '11211';
 
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'memcached_hosts')
-                       ->andReturn([0 => $host . ', 11211']);
+                       ->andReturn([0 => $host . ', ' . $port]);
 
                $logger = new NullLogger();
 
index fb9bc80..62b15bc 100644 (file)
@@ -36,6 +36,7 @@ class RedisCacheLockTest extends LockTest
                $configMock = \Mockery::mock(IConfig::class);
 
                $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
+               $port = $_SERVER['REDIS_PORT'] ?? null;
 
                $configMock
                        ->shouldReceive('get')
@@ -44,7 +45,7 @@ class RedisCacheLockTest extends LockTest
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'redis_port')
-                       ->andReturn(null);
+                       ->andReturn($port);
 
                $configMock
                        ->shouldReceive('get')