Completed
Push — master ( 6f962e...549eec )
by Kamil
21:17
created

SettingsExtensionSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_is_a_Twig_extension() 0 4 1
A it_returns_an_empty_array_if_there_is_no_current_theme_set() 0 6 1
A it_returns_loaded_theme_settings() 0 12 1
A it_has_a_name() 0 4 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\Twig;
13
14
use PhpSpec\ObjectBehavior;
15
use Prophecy\Argument;
16
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
17
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface;
18
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
19
use Sylius\Bundle\ThemeBundle\Settings\ThemeSettingsManagerInterface;
20
use Sylius\Bundle\ThemeBundle\Twig\SettingsExtension;
21
22
/**
23
 * @mixin SettingsExtension
24
 *
25
 * @author Kamil Kokot <[email protected]>
26
 */
27
final class SettingsExtensionSpec extends ObjectBehavior
28
{
29
    function let(ThemeContextInterface $themeContext, ThemeSettingsManagerInterface $themeSettingsManager)
30
    {
31
        $this->beConstructedWith($themeContext, $themeSettingsManager);
32
    }
33
34
    function it_is_initializable()
35
    {
36
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\Twig\SettingsExtension');
37
    }
38
39
    function it_is_a_Twig_extension()
40
    {
41
        $this->shouldHaveType(\Twig_Extension::class);
42
    }
43
44
    function it_returns_an_empty_array_if_there_is_no_current_theme_set(ThemeContextInterface $themeContext)
45
    {
46
        $themeContext->getTheme()->willReturn(null);
47
48
        $this->getThemeSettings()->shouldReturn([]);
49
    }
50
51
    function it_returns_loaded_theme_settings(
52
        ThemeContextInterface $themeContext,
53
        ThemeSettingsManagerInterface $themeSettingsManager,
54
        ThemeInterface $theme,
55
        SettingsInterface $settings
56
    ) {
57
        $themeContext->getTheme()->willReturn($theme);
58
59
        $themeSettingsManager->load($theme)->willReturn($settings);
60
61
        $this->getThemeSettings()->shouldReturn($settings);
62
    }
63
64
    function it_has_a_name()
65
    {
66
        $this->getName()->shouldReturn('sylius_theme_settings');
67
    }
68
}
69