From 0e0102b6fcd17266f39dd63a808740d01ab9bd8a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 24 Sep 2016 19:57:59 +0200 Subject: [PATCH] =?utf8?q?Avoid=20failing=20test=20for=20user=20who=20didn?= =?utf8?q?=E2=80=99t=20install=20Redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../Wallabag/CoreBundle/WallabagCoreTestCase.php | 15 +++++++++++++++ .../Controller/PocketControllerTest.php | 1 + .../Controller/ReadabilityControllerTest.php | 1 + .../Controller/WallabagV1ControllerTest.php | 1 + .../Controller/WallabagV2ControllerTest.php | 1 + 5 files changed, 19 insertions(+) diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php index c0055888..75b7ee0b 100644 --- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php +++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php @@ -80,4 +80,19 @@ abstract class WallabagCoreTestCase extends WebTestCase throw new \RuntimeException('No logged in User.'); } + + /** + * Check if Redis is installed. + * If not, mark test as skip + */ + protected function checkRedis() + { + try { + $this->client->getContainer()->get('wallabag_core.redis.client')->connect(); + } catch (\Exception $e) { + $this->markTestSkipped( + 'Redis is not installed/activated' + ); + } + } } diff --git a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php index 35673261..7d6a300f 100644 --- a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php @@ -34,6 +34,7 @@ class PocketControllerTest extends WallabagCoreTestCase public function testImportPocketWithRedisEnabled() { + $this->checkRedis(); $this->logInAs('admin'); $client = $this->getClient(); diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 7b88d891..87ecb9d3 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php @@ -54,6 +54,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase public function testImportReadabilityWithRedisEnabled() { + $this->checkRedis(); $this->logInAs('admin'); $client = $this->getClient(); diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index 98e85d45..3497c4b8 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php @@ -54,6 +54,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase public function testImportWallabagWithRedisEnabled() { + $this->checkRedis(); $this->logInAs('admin'); $client = $this->getClient(); diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index 74d61f9a..27d2d52b 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php @@ -54,6 +54,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase public function testImportWallabagWithRedisEnabled() { + $this->checkRedis(); $this->logInAs('admin'); $client = $this->getClient(); -- 2.41.0