Completed
Push — master ( 3aaa57...3b1bb7 )
by Aimeos
02:24
created

FlyReplicateTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 54
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 2
A testGetProvider() 0 16 2
A testGetProviderNoSource() 0 11 1
A testGetProviderNoReplica() 0 12 1
1
<?php
2
3
namespace Aimeos\MW\Filesystem;
4
5
6
class FlyReplicateTest extends \PHPUnit_Framework_TestCase
7
{
8
	protected function setUp()
9
	{
10
		if( !interface_exists( '\\League\\Flysystem\\FilesystemInterface' ) ) {
11
			$this->markTestSkipped( 'Install Flysystem first' );
12
		}
13
	}
14
15
16
	public function testGetProvider()
17
	{
18
		if( !class_exists( '\League\Flysystem\Replicate\ReplicateAdapter' ) ) {
19
			$this->markTestSkipped( 'Install Flysystem Replicate adapter' );
20
		}
21
22
		$config = array(
23
			'adapter' => 'Replicate',
24
			'source' => array( 'adapter' => 'FlyMemory' ),
25
			'replica' => array( 'adapter' => 'FlyMemory' ),
26
		);
27
		$object = new FlyReplicate( $config );
28
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
29
30
		$object->has( 'test' );
31
	}
32
33
34
	public function testGetProviderNoSource()
35
	{
36
		$config = array(
37
			'adapter' => 'Replicate',
38
		);
39
		$object = new FlyReplicate( $config );
40
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
41
42
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
43
		$object->has( 'test' );
44
	}
45
46
47
	public function testGetProviderNoReplica()
48
	{
49
		$config = array(
50
			'adapter' => 'Replicate',
51
			'source' => array( 'adapter' => 'FlyMemory' ),
52
		);
53
		$object = new FlyReplicate( $config );
54
		$this->assertInstanceof( '\Aimeos\MW\Filesystem\Iface', $object );
55
56
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
57
		$object->has( 'test' );
58
	}
59
}
60