Completed
Push — scalar-types/theme ( 71f30c )
by Kamil
21:15
created

TestThemeConfigurationManagerSpec   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 62
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 7 1
A letGo() 0 4 1
A it_implements_test_configuration_manager_interface() 0 4 1
A it_finds_all_saved_configurations() 0 4 1
A it_stores_theme_configuration() 0 8 1
A its_theme_configurations_can_be_removed() 0 9 1
A it_clears_all_theme_configurations() 0 12 1
A it_does_not_throw_any_exception_if_clearing_unexisting_storage() 0 4 1
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