Completed
Push — master ( 90ccc1...22512f )
by Kamil
35:43
created

JsonFileLoaderSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace spec\Sylius\Bundle\ThemeBundle\Loader\Filesystem;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\ThemeBundle\Filesystem\FilesystemInterface;
17
use Sylius\Bundle\ThemeBundle\Loader\Filesystem\JsonFileLoader;
18
use Sylius\Bundle\ThemeBundle\Loader\LoaderInterface;
19
20
/**
21
 * @mixin JsonFileLoader
22
 *
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
class JsonFileLoaderSpec extends ObjectBehavior
26
{
27
    function let(FilesystemInterface $filesystem)
28
    {
29
        $this->beConstructedWith($filesystem);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Loader\Filesystem\JsonFileLoader');
35
    }
36
37
    function it_implements_configuration_loader_interface()
38
    {
39
        $this->shouldImplement(LoaderInterface::class);
40
    }
41
42
    function it_loads_json_file(FilesystemInterface $filesystem)
43
    {
44
        $filesystem->exists('/directory/composer.json')->willReturn(true);
45
46
        $filesystem->getFileContents('/directory/composer.json')->willReturn('{ "name": "example/sylius-theme" }');
47
48
        $this->load('/directory/composer.json')->shouldReturn([
49
            'path' => '/directory',
50
            'name' => 'example/sylius-theme',
51
        ]);
52
    }
53
54
    function it_throws_an_exception_if_file_does_not_exist(FilesystemInterface $filesystem)
55
    {
56
        $filesystem->exists('composer.json')->willReturn(false);
57
58
        $this->shouldThrow(\InvalidArgumentException::class)->during('load', ['composer.json']);
59
    }
60
}
61