FsFactoryTest::testCreateExitingOperator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 20
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
rs 9.6
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Filesystem\Test\Unit\Business\FS;
15
16
use League\Flysystem\FilesystemAdapter;
17
use League\Flysystem\FilesystemOperator;
18
use Micro\Plugin\Filesystem\Business\Adapter\AdapterFactoryInterface;
19
use Micro\Plugin\Filesystem\Business\FS\FsFactory;
20
use Micro\Plugin\Filesystem\Configuration\Adapter\FilesystemAdapterConfigurationInterface;
21
use Micro\Plugin\Filesystem\Configuration\FilesystemPluginConfigurationInterface;
22
use PHPUnit\Framework\TestCase;
23
24
class FsFactoryTest extends TestCase
25
{
26
    public function testCreateExitingOperator()
27
    {
28
        $adapterCfg = $this->createMock(FilesystemAdapterConfigurationInterface::class);
29
        $adapterCfg
30
            ->expects($this->once())
31
            ->method('getPublicUrl')
32
            ->willReturn('http://test.com');
33
34
        $cfg = $this->createMock(FilesystemPluginConfigurationInterface::class);
35
        $cfg
36
            ->expects($this->once())
37
            ->method('getAdapterConfiguration')
38
            ->with('test')
39
            ->willReturn($adapterCfg);
40
41
        $adapterFactory = $this->createMock(AdapterFactoryInterface::class);
42
        $adapterFactory
43
            ->expects($this->once())
44
            ->method('create')
45
            ->with($adapterCfg)
46
            ->willReturn($this->createMock(FilesystemAdapter::class));
47
48
        $fsFactory = new FsFactory($cfg, $adapterFactory);
49
50
        $adapter = $fsFactory->create('test');
51
        $this->assertInstanceOf(FilesystemOperator::class, $adapter);
52
    }
53
}
54