Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

ConfigurationTest::getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 2
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 Sylius\Bundle\FixturesBundle\Tests\DependencyInjection;
13
14
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
15
use Sylius\Bundle\FixturesBundle\DependencyInjection\Configuration;
16
17
/**
18
 * @author Kamil Kokot <[email protected]>
19
 */
20
final class ConfigurationTest extends \PHPUnit_Framework_TestCase
21
{
22
    use ConfigurationTestCaseTrait;
23
24
    /**
25
     * @test
26
     */
27
    public function suite_can_have_one_fixture()
28
    {
29
        $this->assertConfigurationIsValid(
30
            [['suites' => ['suite' => ['fixtures' => ['fixture' => null]]]]],
31
            'suites.*.fixtures'
32
        );
33
    }
34
35
    /**
36
     * @test
37
     */
38
    public function multiple_suites_are_allowed()
39
    {
40
        $this->assertConfigurationIsValid(
41
            [['suites' => [
42
                'first_suite' => ['fixtures' => ['fixture' => null]],
43
                'second_suite' => ['fixtures' => ['fixture' => null]],
44
            ]]],
45
            'suites.*.fixtures'
46
        );
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function consecutive_configurations_can_add_suites()
53
    {
54
        $this->assertProcessedConfigurationEquals(
55
            [
56
                ['suites' => [
57
                    'first_suite' => ['fixtures' => ['fixture' => null]],
58
                ]],
59
                ['suites' => [
60
                    'second_suite' => ['fixtures' => ['fixture' => null]],
61
                ]],
62
            ],
63
            ['suites' => [
64
                'first_suite' => ['fixtures' => ['fixture' => ['options' => [[]], 'priority' => 0]]],
65
                'second_suite' => ['fixtures' => ['fixture' => ['options' => [[]], 'priority' => 0]]],
66
            ]],
67
            'suites.*.fixtures'
68
        );
69
    }
70
71
    /**
72
     * @test
73
     */
74
    public function suite_can_have_multiple_fixtures()
75
    {
76
        $this->assertConfigurationIsValid(
77
            [['suites' => ['suite' => ['fixtures' => [
78
                'first_fixture' => null,
79
                'second_fixture' => null,
80
            ]]]]],
81
            'suites.*.fixtures'
82
        );
83
    }
84
85
    /**
86
     * @test
87
     */
88
    public function consecutive_configurations_can_remove_a_fixture_from_the_suite()
89
    {
90
        $this->assertProcessedConfigurationEquals(
91
            [
92
                ['suites' => ['suite' => ['fixtures' => [
93
                    'first_fixture' => null,
94
                    'second_fixture' => null,
95
                ]]]],
96
                ['suites' => ['suite' => ['fixtures' => [
97
                    'second_fixture' => false,
98
                ]]]],
99
            ],
100
            ['suites' => ['suite' => ['fixtures' => [
101
                'first_fixture' => ['options' => [[]], 'priority' => 0],
102
            ]]]],
103
            'suites.*.fixtures'
104
        );
105
    }
106
107
    /**
108
     * @test
109
     */
110
    public function consecutive_configurations_can_add_fixtures_to_the_suite()
111
    {
112
        $this->assertProcessedConfigurationEquals(
113
            [
114
                ['suites' => ['suite' => ['fixtures' => [
115
                    'first_fixture' => null,
116
                ]]]],
117
                ['suites' => ['suite' => ['fixtures' => [
118
                    'second_fixture' => null,
119
                ]]]],
120
            ],
121
            ['suites' => ['suite' => ['fixtures' => [
122
                'first_fixture' => ['options' => [[]], 'priority' => 0],
123
                'second_fixture' => ['options' => [[]], 'priority' => 0],
124
            ]]]],
125
            'suites.*.fixtures'
126
        );
127
    }
128
129
    /**
130
     * @test
131
     */
132
    public function all_fixture_options_from_consecutive_configurations_are_collected()
133
    {
134
        $this->assertProcessedConfigurationEquals(
135
            [
136
                ['suites' => ['suite' => ['fixtures' => [
137
                    'fixture' => ['options' => ['option' => 4]],
138
                ]]]],
139
                ['suites' => ['suite' => ['fixtures' => [
140
                    'fixture' => ['options' => ['option' => 2]],
141
                ]]]],
142
            ],
143
            ['suites' => ['suite' => ['fixtures' => [
144
                'fixture' => ['options' => [['option' => 4], ['option' => 2]], 'priority' => 0],
145
            ]]]],
146
            'suites.*.fixtures'
147
        );
148
    }
149
150
    /**
151
     * @test
152
     */
153
    public function fixture_options_are_not_replaced_implicitly()
154
    {
155
        $this->assertProcessedConfigurationEquals(
156
            [
157
                ['suites' => ['suite' => ['fixtures' => [
158
                    'fixture' => ['options' => ['option' => 4]],
159
                ]]]],
160
                ['suites' => ['suite' => ['fixtures' => [
161
                    'fixture' => null,
162
                ]]]],
163
            ],
164
            ['suites' => ['suite' => ['fixtures' => [
165
                'fixture' => ['options' => [['option' => 4]], 'priority' => 0],
166
            ]]]],
167
            'suites.*.fixtures'
168
        );
169
    }
170
171
    /**
172
     * {@inheritdoc}
173
     */
174
    protected function getConfiguration()
175
    {
176
        return new Configuration();
177
    }
178
}
179