|
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; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Prophecy\Argument; |
|
16
|
|
|
use Sylius\Bundle\ThemeBundle\Loader\ConfigurationProcessingLoader; |
|
17
|
|
|
use Sylius\Bundle\ThemeBundle\Loader\ConfigurationProcessorInterface; |
|
18
|
|
|
use Sylius\Bundle\ThemeBundle\Loader\LoaderInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @mixin ConfigurationProcessingLoader |
|
22
|
|
|
* |
|
23
|
|
|
* @author Kamil Kokot <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class ConfigurationProcessingLoaderSpec extends ObjectBehavior |
|
26
|
|
|
{ |
|
27
|
|
|
function let(LoaderInterface $decoratedLoader, ConfigurationProcessorInterface $configurationProcessor) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->beConstructedWith($decoratedLoader, $configurationProcessor); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function it_is_initializable() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->shouldHaveType('Sylius\Bundle\ThemeBundle\Loader\ConfigurationProcessingLoader'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function it_implements_loader_interface() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->shouldImplement(LoaderInterface::class); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function it_processes_the_configuration( |
|
43
|
|
|
LoaderInterface $decoratedLoader, |
|
44
|
|
|
ConfigurationProcessorInterface $configurationProcessor |
|
45
|
|
|
) { |
|
46
|
|
|
$basicConfiguration = ['name' => 'example/sylius-theme']; |
|
47
|
|
|
|
|
48
|
|
|
$decoratedLoader->load('theme-configuration-resource')->willReturn($basicConfiguration); |
|
49
|
|
|
|
|
50
|
|
|
$configurationProcessor->process([$basicConfiguration])->willReturn([ |
|
51
|
|
|
'name' => 'example/sylius-theme', |
|
52
|
|
|
]); |
|
53
|
|
|
|
|
54
|
|
|
$this->load('theme-configuration-resource')->shouldReturn([ |
|
55
|
|
|
'name' => 'example/sylius-theme', |
|
56
|
|
|
]); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
function it_processes_the_configuration_and_extracts_extra_sylius_theme_key_as_another_configuration( |
|
60
|
|
|
LoaderInterface $decoratedLoader, |
|
61
|
|
|
ConfigurationProcessorInterface $configurationProcessor |
|
62
|
|
|
) { |
|
63
|
|
|
$basicConfiguration = [ |
|
64
|
|
|
'name' => 'example/sylius-theme', |
|
65
|
|
|
'extra' => [ |
|
66
|
|
|
'sylius-theme' => [ |
|
67
|
|
|
'name' => 'example/brand-new-sylius-theme', |
|
68
|
|
|
], |
|
69
|
|
|
], |
|
70
|
|
|
]; |
|
71
|
|
|
|
|
72
|
|
|
$decoratedLoader->load('theme-configuration-resource')->willReturn($basicConfiguration); |
|
73
|
|
|
|
|
74
|
|
|
$configurationProcessor->process([ |
|
75
|
|
|
$basicConfiguration, |
|
76
|
|
|
['name' => 'example/brand-new-sylius-theme'], |
|
77
|
|
|
])->willReturn([ |
|
78
|
|
|
'name' => 'example/brand-new-sylius-theme', |
|
79
|
|
|
]); |
|
80
|
|
|
|
|
81
|
|
|
$this->load('theme-configuration-resource')->shouldReturn([ |
|
82
|
|
|
'name' => 'example/brand-new-sylius-theme', |
|
83
|
|
|
]); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|