Completed
Push — master ( 9c14a5...11d3c4 )
by Aimeos
02:55
created

LaravelTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 14 2
A tearDown() 0 7 1
A testGet() 0 12 1
A testGetFallback() 0 5 1
A testGetException() 0 5 1
1
<?php
2
3
namespace Aimeos\MW\Filesystem\Manager;
4
5
6
class LaravelTest extends \PHPUnit_Framework_TestCase
7
{
8
	private $config;
9
	private $object;
10
	private $storage;
11
12
13
	protected function setUp()
14
	{
15
		if( !class_exists( '\Illuminate\Filesystem\FilesystemManager' ) ) {
16
			$this->markTestSkipped( 'Install the Laravel framework first' );
17
		}
18
19
		$this->storage = $this->getMockBuilder( '\Illuminate\Filesystem\FilesystemManager' )
20
			->setMethods( array( 'get' ) )
21
			->disableOriginalConstructor()
22
			->getMock();
23
24
		$this->config = new \Aimeos\MW\Config\PHPArray( array(), array() );
25
		$this->object = new \Aimeos\MW\Filesystem\Manager\Laravel( $this->storage, $this->config );
26
	}
27
28
29
	protected function tearDown()
30
	{
31
		$this->config->set( 'resource/fs-media', null );
32
		$this->config->set( 'resource/fs', null );
33
34
		unset( $this->object, $this->storage );
35
	}
36
37
38
	public function testGet()
39
	{
40
		$fs = $this->getMockBuilder( 'Illuminate\Contracts\Filesystem\Filesystem' )
41
			->disableOriginalConstructor()
42
			->getMock();
43
44
		$this->storage->expects( $this->once() )->method( 'get' )
45
			->will( $this->returnValue( $fs ) );
46
47
		$this->config->set( 'resource/fs-media', 'local' );
48
		$this->assertInstanceof( 'Aimeos\MW\Filesystem\Iface', $this->object->get( 'fs-media' ) );
49
	}
50
51
52
	public function testGetFallback()
53
	{
54
		$this->config->set( 'resource/fs', array( 'adapter' => 'Standard', 'basedir' => __DIR__ ) );
55
		$this->assertInstanceof( 'Aimeos\MW\Filesystem\Iface', $this->object->get( 'fs-media' ) );
56
	}
57
58
59
	public function testGetException()
60
	{
61
		$this->setExpectedException( 'Aimeos\MW\Filesystem\Exception' );
62
		$this->object->get( 'fs-media' );
63
	}
64
}
65