Completed
Push — master ( 4207f0...333332 )
by Kamil
23:19 queued 01:42
created

ThemeHierarchyProviderSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_theme_hierarchy_provider_interface() 0 4 1
A it_returns_theme_list_in_hierarchized_order() 0 13 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\Resolver;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProviderInterface;
16
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
17
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface;
18
use Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeHierarchyProvider;
19
20
/**
21
 * @mixin ThemeHierarchyProvider
22
 *
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
class ThemeHierarchyProviderSpec extends ObjectBehavior
26
{
27
    function let(ThemeRepositoryInterface $themeRepository)
28
    {
29
        $this->beConstructedWith($themeRepository);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Bundle\ThemeBundle\HierarchyProvider\ThemeDependenciesResolver');
35
    }
36
37
    function it_implements_theme_hierarchy_provider_interface()
38
    {
39
        $this->shouldImplement(ThemeHierarchyProviderInterface::class);
40
    }
41
42
    function it_returns_theme_list_in_hierarchized_order(ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme)
43
    {
44
        $firstTheme->getSlug()->willReturn("foo/bar1");
45
        $firstTheme->getParentsSlugs()->willReturn(["foo/bar2"]);
46
47
        $secondTheme->getSlug()->willReturn("foo/bar2");
48
        $secondTheme->getParentsSlugs()->willReturn([]);
49
50
        $themeRepository->findOneBySlug("foo/bar1")->willReturn($firstTheme);
51
        $themeRepository->findOneBySlug("foo/bar2")->willReturn($secondTheme);
52
53
        $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]);
54
    }
55
56
}
57