|
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\Settings; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Prophecy\Argument; |
|
16
|
|
|
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface; |
|
17
|
|
|
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface; |
|
18
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; |
|
19
|
|
|
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface; |
|
20
|
|
|
use Sylius\Bundle\ThemeBundle\Settings\ThemeSettingsManager; |
|
21
|
|
|
use Sylius\Bundle\ThemeBundle\Settings\ThemeSettingsManagerInterface; |
|
22
|
|
|
use Sylius\Bundle\ThemeBundle\Settings\ThemeSettingsSchemaProviderInterface; |
|
23
|
|
|
use Sylius\Component\Registry\ServiceRegistryInterface; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @mixin ThemeSettingsManager |
|
27
|
|
|
* |
|
28
|
|
|
* @author Kamil Kokot <[email protected]> |
|
29
|
|
|
*/ |
|
30
|
|
|
final class ThemeSettingsManagerSpec extends ObjectBehavior |
|
31
|
|
|
{ |
|
32
|
|
|
function let( |
|
33
|
|
|
SettingsManagerInterface $decoratedSettingsManager, |
|
34
|
|
|
ServiceRegistryInterface $schemaRegistry, |
|
35
|
|
|
ThemeSettingsSchemaProviderInterface $themeSettingsSchemaProvider |
|
36
|
|
|
) { |
|
37
|
|
|
$this->beConstructedWith($decoratedSettingsManager, $schemaRegistry, $themeSettingsSchemaProvider); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_is_initializable() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->shouldHaveType('Sylius\Bundle\ThemeBundle\Settings\ThemeSettingsManager'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_implements_theme_settings_manager_interface() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->shouldImplement(ThemeSettingsManagerInterface::class); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function it_transforms_theme_to_schema_alias_during_loading_settings( |
|
51
|
|
|
SettingsManagerInterface $decoratedSettingsManager, |
|
52
|
|
|
ServiceRegistryInterface $schemaRegistry, |
|
53
|
|
|
ThemeInterface $theme, |
|
54
|
|
|
SettingsInterface $settings |
|
55
|
|
|
) { |
|
56
|
|
|
$theme->getCode()->willReturn('DEADBEEF'); |
|
57
|
|
|
|
|
58
|
|
|
$schemaRegistry->has('theme_DEADBEEF')->willReturn(true); |
|
59
|
|
|
$schemaRegistry->register(Argument::cetera())->shouldNotBeCalled(); |
|
60
|
|
|
|
|
61
|
|
|
$decoratedSettingsManager->load('theme_DEADBEEF', null)->willReturn($settings); |
|
62
|
|
|
|
|
63
|
|
|
$this->load($theme)->shouldReturn($settings); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function it_registers_theme_schema_alias_if_not_exists_during_loading_settings( |
|
67
|
|
|
SettingsManagerInterface $decoratedSettingsManager, |
|
68
|
|
|
ServiceRegistryInterface $schemaRegistry, |
|
69
|
|
|
ThemeSettingsSchemaProviderInterface $themeSettingsSchemaProvider, |
|
70
|
|
|
ThemeInterface $theme, |
|
71
|
|
|
SettingsInterface $settings, |
|
72
|
|
|
SchemaInterface $schema |
|
73
|
|
|
) { |
|
74
|
|
|
$theme->getCode()->willReturn('DEADBEEF'); |
|
75
|
|
|
|
|
76
|
|
|
$schemaRegistry->has('theme_DEADBEEF')->willReturn(false); |
|
77
|
|
|
|
|
78
|
|
|
$themeSettingsSchemaProvider->getSchema($theme)->willReturn($schema); |
|
79
|
|
|
|
|
80
|
|
|
$schemaRegistry->register('theme_DEADBEEF', $schema)->shouldBeCalled(); |
|
81
|
|
|
|
|
82
|
|
|
$decoratedSettingsManager->load('theme_DEADBEEF', null)->willReturn($settings); |
|
83
|
|
|
|
|
84
|
|
|
$this->load($theme)->shouldReturn($settings); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
function it_delegates_saving_settings_to_decorated_settings_manager( |
|
88
|
|
|
SettingsManagerInterface $decoratedSettingsManager, |
|
89
|
|
|
SettingsInterface $settings |
|
90
|
|
|
) { |
|
91
|
|
|
$decoratedSettingsManager->save($settings)->shouldBeCalled(); |
|
92
|
|
|
|
|
93
|
|
|
$this->save($settings); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|