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
|
|
|
|