From: Jeremy Benoist Date: Sat, 24 Sep 2016 17:57:59 +0000 (+0200) Subject: Avoid failing test for user who didn’t install Redis X-Git-Tag: 2.1.0~28^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=0e0102b6fcd17266f39dd63a808740d01ab9bd8a;hp=13a522dfbd64d1eb14b6e3715289753b0506ded0;p=github%2Fwallabag%2Fwallabag.git Avoid failing test for user who didn’t install Redis --- 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();