Passed
Pull Request — master (#407)
by Kirill
06:33
created

FileSystemInfoTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidateNoAdapterClassFailed() 0 13 1
A testValidateNoOptionsFailed() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Tests\Storage\Unit\Config\DTO\FileSystemInfo;
6
7
use League\Flysystem\Local\LocalFilesystemAdapter;
8
use Spiral\Storage\Exception\ConfigException;
9
use Spiral\Storage\Config\DTO\FileSystemInfo\LocalInfo;
10
use Spiral\Storage\Exception\StorageException;
11
use Spiral\Tests\Storage\Unit\UnitTestCase;
12
13
class FileSystemInfoTest extends UnitTestCase
14
{
15
    /**
16
     * @throws StorageException
17
     */
18
    public function testValidateNoOptionsFailed(): void
19
    {
20
        $fsName = 'some';
21
22
        $this->expectException(ConfigException::class);
23
        $this->expectExceptionMessage(\sprintf('Filesystem `%s` needs options defined', $fsName));
24
25
        new LocalInfo(
26
            $fsName,
27
            [LocalInfo::ADAPTER_KEY => LocalFilesystemAdapter::class]
28
        );
29
    }
30
31
    /**
32
     * @throws StorageException
33
     */
34
    public function testValidateNoAdapterClassFailed(): void
35
    {
36
        $fsName = 'some';
37
38
        $this->expectException(ConfigException::class);
39
        $this->expectExceptionMessage(\sprintf('Filesystem `%s` needs adapter class defined', $fsName));
40
41
        new LocalInfo(
42
            $fsName,
43
            [
44
                LocalInfo::OPTIONS_KEY => [
45
                    LocalInfo::ROOT_DIR_KEY => '/some/root/',
46
                    LocalInfo::HOST_KEY => self::CONFIG_HOST,
47
                ],
48
            ]
49
        );
50
    }
51
}
52