|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Sylius\Bundle\ThemeBundle\Tests\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait; |
|
17
|
|
|
use Sylius\Bundle\ThemeBundle\DependencyInjection\Configuration; |
|
18
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
19
|
|
|
|
|
20
|
|
|
final class ConfigurationTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
use ConfigurationTestCaseTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @test |
|
26
|
|
|
*/ |
|
27
|
|
|
public function it_has_default_context_service_set(): void |
|
28
|
|
|
{ |
|
29
|
|
|
$this->assertProcessedConfigurationEquals( |
|
30
|
|
|
[ |
|
31
|
|
|
[], |
|
32
|
|
|
], |
|
33
|
|
|
['context' => 'sylius.theme.context.settable'], |
|
34
|
|
|
'context' |
|
35
|
|
|
); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @test |
|
40
|
|
|
*/ |
|
41
|
|
|
public function its_context_cannot_be_empty(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$this->assertPartialConfigurationIsInvalid( |
|
44
|
|
|
[ |
|
45
|
|
|
[''], |
|
46
|
|
|
], |
|
47
|
|
|
'context' |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @test |
|
53
|
|
|
*/ |
|
54
|
|
|
public function its_context_can_be_overridden(): void |
|
55
|
|
|
{ |
|
56
|
|
|
$this->assertProcessedConfigurationEquals( |
|
57
|
|
|
[ |
|
58
|
|
|
['context' => 'sylius.theme.context.custom'], |
|
59
|
|
|
], |
|
60
|
|
|
['context' => 'sylius.theme.context.custom'], |
|
61
|
|
|
'context' |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @test |
|
67
|
|
|
*/ |
|
68
|
|
|
public function assets_support_is_enabled_by_default() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->assertProcessedConfigurationEquals([[]], ['assets' => ['enabled' => true]], 'assets'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @test |
|
75
|
|
|
*/ |
|
76
|
|
|
public function assets_support_may_be_toggled() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->assertProcessedConfigurationEquals([['assets' => ['enabled' => true]]], ['assets' => ['enabled' => true]], 'assets'); |
|
79
|
|
|
$this->assertProcessedConfigurationEquals([['assets' => []]], ['assets' => ['enabled' => true]], 'assets'); |
|
80
|
|
|
$this->assertProcessedConfigurationEquals([['assets' => null]], ['assets' => ['enabled' => true]], 'assets'); |
|
81
|
|
|
|
|
82
|
|
|
$this->assertProcessedConfigurationEquals([['assets' => ['enabled' => false]]], ['assets' => ['enabled' => false]], 'assets'); |
|
83
|
|
|
$this->assertProcessedConfigurationEquals([['assets' => false]], ['assets' => ['enabled' => false]], 'assets'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @test |
|
88
|
|
|
*/ |
|
89
|
|
|
public function templating_support_is_enabled_by_default() |
|
90
|
|
|
{ |
|
91
|
|
|
$this->assertProcessedConfigurationEquals([[]], ['templating' => ['enabled' => true]], 'templating'); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @test |
|
96
|
|
|
*/ |
|
97
|
|
|
public function templating_support_may_be_toggled() |
|
98
|
|
|
{ |
|
99
|
|
|
$this->assertProcessedConfigurationEquals([['templating' => ['enabled' => true]]], ['templating' => ['enabled' => true]], 'templating'); |
|
100
|
|
|
$this->assertProcessedConfigurationEquals([['templating' => []]], ['templating' => ['enabled' => true]], 'templating'); |
|
101
|
|
|
$this->assertProcessedConfigurationEquals([['templating' => null]], ['templating' => ['enabled' => true]], 'templating'); |
|
102
|
|
|
|
|
103
|
|
|
$this->assertProcessedConfigurationEquals([['templating' => ['enabled' => false]]], ['templating' => ['enabled' => false]], 'templating'); |
|
104
|
|
|
$this->assertProcessedConfigurationEquals([['templating' => false]], ['templating' => ['enabled' => false]], 'templating'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @test |
|
109
|
|
|
*/ |
|
110
|
|
|
public function translations_support_is_enabled_by_default() |
|
111
|
|
|
{ |
|
112
|
|
|
$this->assertProcessedConfigurationEquals([[]], ['translations' => ['enabled' => true]], 'translations'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @test |
|
117
|
|
|
*/ |
|
118
|
|
|
public function translations_support_may_be_toggled() |
|
119
|
|
|
{ |
|
120
|
|
|
$this->assertProcessedConfigurationEquals([['translations' => ['enabled' => true]]], ['translations' => ['enabled' => true]], 'translations'); |
|
121
|
|
|
$this->assertProcessedConfigurationEquals([['translations' => []]], ['translations' => ['enabled' => true]], 'translations'); |
|
122
|
|
|
$this->assertProcessedConfigurationEquals([['translations' => null]], ['translations' => ['enabled' => true]], 'translations'); |
|
123
|
|
|
|
|
124
|
|
|
$this->assertProcessedConfigurationEquals([['translations' => ['enabled' => false]]], ['translations' => ['enabled' => false]], 'translations'); |
|
125
|
|
|
$this->assertProcessedConfigurationEquals([['translations' => false]], ['translations' => ['enabled' => false]], 'translations'); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* {@inheritdoc} |
|
130
|
|
|
*/ |
|
131
|
|
|
protected function getConfiguration(): ConfigurationInterface |
|
132
|
|
|
{ |
|
133
|
|
|
return new Configuration(); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|