]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/Lock/RedisCacheLockTest.php
Merge pull request #10666 from tobiasd/20210905-credits
[friendica.git] / tests / src / Core / Lock / RedisCacheLockTest.php
index 95f7206e2c79d73367c2f12bd9b8da98c2b54462..360fa74fb2b1a043d7d25542684d6270e4d22d61 100644 (file)
@@ -1,11 +1,31 @@
 <?php
-
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Test\src\Core\Lock;
 
+use Exception;
 use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfig;
 use Friendica\Core\Lock\CacheLock;
+use Mockery;
 
 /**
  * @requires extension redis
@@ -15,9 +35,10 @@ class RedisCacheLockTest extends LockTest
 {
        protected function getInstance()
        {
-               $configMock = \Mockery::mock(Configuration::class);
+               $configMock = Mockery::mock(IConfig::class);
 
                $host = $_SERVER['REDIS_HOST'] ?? 'localhost';
+               $port = $_SERVER['REDIS_PORT'] ?? 6379;
 
                $configMock
                        ->shouldReceive('get')
@@ -26,12 +47,12 @@ class RedisCacheLockTest extends LockTest
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'redis_port')
-                       ->andReturn(null);
+                       ->andReturn($port);
 
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'redis_db', 0)
-                       ->andReturn(3);
+                       ->andReturn(0);
                $configMock
                        ->shouldReceive('get')
                        ->with('system', 'redis_password')
@@ -42,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. Error: ' . $e->getMessage());
                }
 
                return $lock;