DoctrineRedisIntegrationTest::setUp()   B
last analyzed

Complexity

Conditions 5
Paths 16

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 26
rs 8.439
cc 5
eloc 14
nc 16
nop 0
1
<?php
2
3
namespace Onoi\BlobStore\Tests\Integration;
4
5
use Onoi\Cache\CacheFactory;
6
use Doctrine\Common\Cache\RedisCache;
7
8
/**
9
 * @group onoi-blobstore
10
 *
11
 * @license GNU GPL v2+
12
 * @since 1.0
13
 *
14
 * @author mwjames
15
 */
16
class DoctrineRedisIntegrationTest extends BlobStoreIntegrationTestCase {
17
18
	protected function setUp() {
19
20
		if ( !class_exists( '\Onoi\Cache\CacheFactory' ) ) {
21
			$this->markTestSkipped( 'CacheFactory is not available' );
22
		}
23
24
		if ( !class_exists( '\Redis' ) ) {
25
			$this->markTestSkipped( 'Requires redis php-class/extension to be available' );
26
		}
27
28
		$redis = new \Redis();
29
30
		if ( !$redis->connect( '127.0.0.1' ) ) {
31
			$this->markTestSkipped( 'Cannot connect to redis' );
32
		}
33
34
		if ( !class_exists( '\Doctrine\Common\Cache\RedisCache' ) ) {
35
			$this->markTestSkipped( 'RedisCache is not available' );
36
		}
37
38
		$redisCache = new RedisCache();
39
		$redisCache->setRedis( $redis );
40
41
		$cacheFactory = new CacheFactory();
42
		$this->cache = $cacheFactory->newDoctrineCache( $redisCache );
43
	}
44
45
}
46