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

JsonFileLoaderSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 36
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_configuration_loader_interface() 0 4 1
A it_loads_json_file() 0 11 1
A it_throws_an_exception_if_file_does_not_exist() 0 6 1
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