|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Base\Filesystem\Manager; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class LaravelTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $storage; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
protected function setUp() : void |
|
18
|
|
|
{ |
|
19
|
|
|
if( !class_exists( '\Illuminate\Filesystem\FilesystemManager' ) ) { |
|
20
|
|
|
$this->markTestSkipped( 'Install the Laravel framework first' ); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
$this->storage = $this->getMockBuilder( \Illuminate\Filesystem\FilesystemManager::class ) |
|
24
|
|
|
->onlyMethods( array( 'get' ) ) |
|
25
|
|
|
->disableOriginalConstructor() |
|
26
|
|
|
->getMock(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
protected function tearDown() : void |
|
31
|
|
|
{ |
|
32
|
|
|
unset( $this->storage ); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
public function testGet() |
|
37
|
|
|
{ |
|
38
|
|
|
$fs = $this->getMockBuilder( 'Illuminate\Contracts\Filesystem\Filesystem' ) |
|
39
|
|
|
->disableOriginalConstructor() |
|
40
|
|
|
->getMock(); |
|
41
|
|
|
|
|
42
|
|
|
$this->storage->expects( $this->once() )->method( 'get' ) |
|
43
|
|
|
->willReturn( $fs ); |
|
44
|
|
|
|
|
45
|
|
|
$object = new \Aimeos\Base\Filesystem\Manager\Laravel( $this->storage, ['fs-media' => 'local'], sys_get_temp_dir() ); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertInstanceof( 'Aimeos\Base\Filesystem\Iface', $object->get( 'fs-media' ) ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
public function testGetFallback() |
|
52
|
|
|
{ |
|
53
|
|
|
$config = ['fs' => ['adapter' => 'Standard', 'basedir' => __DIR__]]; |
|
54
|
|
|
$object = new \Aimeos\Base\Filesystem\Manager\Laravel( $this->storage, $config, sys_get_temp_dir() ); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertInstanceof( 'Aimeos\Base\Filesystem\Iface', $object->get( 'fs-media' ) ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
public function testGetException() |
|
61
|
|
|
{ |
|
62
|
|
|
$object = new \Aimeos\Base\Filesystem\Manager\Laravel( $this->storage, [], sys_get_temp_dir() ); |
|
63
|
|
|
|
|
64
|
|
|
$this->expectException( 'Aimeos\Base\Filesystem\Exception' ); |
|
65
|
|
|
$object->get( 'fs-media' ); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|