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\FilesystemSource; |
15
|
|
|
|
16
|
|
|
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait; |
17
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\Filesystem\FilesystemConfigurationSourceFactory; |
18
|
|
|
use Sylius\Bundle\ThemeBundle\DependencyInjection\Configuration; |
19
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
20
|
|
|
|
21
|
|
|
final class ConfigurationTest extends \PHPUnit_Framework_TestCase |
22
|
|
|
{ |
23
|
|
|
use ConfigurationTestCaseTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @test |
27
|
|
|
*/ |
28
|
|
|
public function it_uses_app_themes_filesystem_as_the_default_source(): void |
29
|
|
|
{ |
30
|
|
|
$this->assertProcessedConfigurationEquals( |
31
|
|
|
[ |
32
|
|
|
['sources' => ['filesystem' => null]], |
33
|
|
|
], |
34
|
|
|
['sources' => ['filesystem' => [ |
35
|
|
|
'directories' => ['%kernel.root_dir%/themes'], |
36
|
|
|
'filename' => 'composer.json', |
37
|
|
|
'enabled' => true, |
38
|
|
|
]]], |
39
|
|
|
'sources' |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @test |
45
|
|
|
*/ |
46
|
|
|
public function it_does_not_add_default_theme_directories_if_there_are_some_defined_by_user(): void |
47
|
|
|
{ |
48
|
|
|
$this->assertProcessedConfigurationEquals( |
49
|
|
|
[ |
50
|
|
|
['sources' => ['filesystem' => ['directories' => ['/custom/path', '/custom/path2']]]], |
51
|
|
|
], |
52
|
|
|
['sources' => ['filesystem' => [ |
53
|
|
|
'directories' => ['/custom/path', '/custom/path2'], |
54
|
|
|
'filename' => 'composer.json', |
55
|
|
|
'enabled' => true, |
56
|
|
|
]]], |
57
|
|
|
'sources.filesystem' |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @test |
63
|
|
|
*/ |
64
|
|
|
public function it_uses_the_last_theme_directories_passed_and_rejects_the_other_ones(): void |
65
|
|
|
{ |
66
|
|
|
$this->assertProcessedConfigurationEquals( |
67
|
|
|
[ |
68
|
|
|
['sources' => ['filesystem' => ['directories' => ['/custom/path', '/custom/path2']]]], |
69
|
|
|
['sources' => ['filesystem' => ['directories' => ['/last/custom/path']]]], |
70
|
|
|
], |
71
|
|
|
['sources' => ['filesystem' => [ |
72
|
|
|
'directories' => ['/last/custom/path'], |
73
|
|
|
'filename' => 'composer.json', |
74
|
|
|
'enabled' => true, |
75
|
|
|
]]], |
76
|
|
|
'sources.filesystem' |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @test |
82
|
|
|
*/ |
83
|
|
|
public function it_is_invalid_to_pass_a_string_as_theme_directories(): void |
84
|
|
|
{ |
85
|
|
|
$this->assertPartialConfigurationIsInvalid( |
86
|
|
|
[ |
87
|
|
|
['directories' => '/string/not/array'], |
88
|
|
|
], |
89
|
|
|
'sources.filesystem' |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @test |
95
|
|
|
*/ |
96
|
|
|
public function it_throws_an_error_if_trying_to_set_theme_directories_to_an_empty_array(): void |
97
|
|
|
{ |
98
|
|
|
$this->assertPartialConfigurationIsInvalid( |
99
|
|
|
[ |
100
|
|
|
['directories' => []], |
101
|
|
|
], |
102
|
|
|
'sources.filesystem' |
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* {@inheritdoc} |
108
|
|
|
*/ |
109
|
|
|
protected function getConfiguration(): ConfigurationInterface |
110
|
|
|
{ |
111
|
|
|
return new Configuration([ |
112
|
|
|
new FilesystemConfigurationSourceFactory(), |
113
|
|
|
]); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|