Passed
Push — master ( 894e98...cda682 )
by Aimeos
18:42 queued 10:10
created

FlyReplicateTest::testGetProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 0
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Aimeos\Base\Filesystem;
4
5
6
class FlyReplicateTest extends \PHPUnit\Framework\TestCase
7
{
8
	protected function setUp() : void
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\Base\Filesystem\Iface::class, $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\Base\Filesystem\Iface::class, $object );
41
42
		$this->expectException( 'Aimeos\Base\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\Base\Filesystem\Iface::class, $object );
55
56
		$this->expectException( 'Aimeos\Base\Filesystem\Exception' );
57
		$object->has( 'test' );
58
	}
59
}
60