DoctrineRedisIntegrationTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B setUp() 0 26 5
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