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 spec\Sylius\Bundle\ThemeBundle\Configuration\Test; |
15
|
|
|
|
16
|
|
|
use org\bovigo\vfs\vfsStreamDirectory as VfsStreamDirectory; |
17
|
|
|
use org\bovigo\vfs\vfsStreamWrapper as VfsStreamWrapper; |
18
|
|
|
use PhpSpec\ObjectBehavior; |
19
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProcessorInterface; |
20
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\Test\TestThemeConfigurationManager; |
21
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\Test\TestThemeConfigurationManagerInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Kamil Kokot <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
final class TestThemeConfigurationManagerSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function let(ConfigurationProcessorInterface $configurationProcessor): void |
29
|
|
|
{ |
30
|
|
|
VfsStreamWrapper::register(); |
31
|
|
|
VfsStreamWrapper::setRoot(new VfsStreamDirectory('')); |
32
|
|
|
|
33
|
|
|
$this->beConstructedWith($configurationProcessor, 'vfs://cache/'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function letGo(): void |
37
|
|
|
{ |
38
|
|
|
VfsStreamWrapper::unregister(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_implements_test_configuration_manager_interface(): void |
42
|
|
|
{ |
43
|
|
|
$this->shouldImplement(TestThemeConfigurationManagerInterface::class); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function it_finds_all_saved_configurations(): void |
47
|
|
|
{ |
48
|
|
|
$this->findAll()->shouldReturn([]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_stores_theme_configuration(ConfigurationProcessorInterface $configurationProcessor): void |
52
|
|
|
{ |
53
|
|
|
$configurationProcessor->process([['name' => 'theme/name']])->willReturn(['name' => 'theme/name']); |
54
|
|
|
|
55
|
|
|
$this->add(['name' => 'theme/name']); |
56
|
|
|
|
57
|
|
|
$this->findAll()->shouldHaveCount(1); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
function its_theme_configurations_can_be_removed(ConfigurationProcessorInterface $configurationProcessor): void |
61
|
|
|
{ |
62
|
|
|
$configurationProcessor->process([['name' => 'theme/name']])->willReturn(['name' => 'theme/name']); |
63
|
|
|
|
64
|
|
|
$this->add(['name' => 'theme/name']); |
65
|
|
|
$this->remove('theme/name'); |
66
|
|
|
|
67
|
|
|
$this->findAll()->shouldReturn([]); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
function it_clears_all_theme_configurations(ConfigurationProcessorInterface $configurationProcessor): void |
71
|
|
|
{ |
72
|
|
|
$configurationProcessor->process([['name' => 'theme/name1']])->willReturn(['name' => 'theme/name1']); |
73
|
|
|
$configurationProcessor->process([['name' => 'theme/name2']])->willReturn(['name' => 'theme/name2']); |
74
|
|
|
|
75
|
|
|
$this->add(['name' => 'theme/name1']); |
76
|
|
|
$this->add(['name' => 'theme/name2']); |
77
|
|
|
|
78
|
|
|
$this->clear(); |
79
|
|
|
|
80
|
|
|
$this->findAll()->shouldReturn([]); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
function it_does_not_throw_any_exception_if_clearing_unexisting_storage(): void |
84
|
|
|
{ |
85
|
|
|
$this->clear(); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|