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
|
|
|
|