|
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\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
|
15
|
|
|
use Sylius\Bundle\FixturesBundle\DependencyInjection\SyliusFixturesExtension; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author Kamil Kokot <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
final class SyliusFixturesExtensionTest extends AbstractExtensionTestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @test |
|
25
|
|
|
*/ |
|
26
|
|
|
public function it_does_not_crash_if_no_suite_is_configured() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->load(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @test |
|
33
|
|
|
*/ |
|
34
|
|
|
public function it_registers_configured_suites() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->load(['suites' => [ |
|
37
|
|
|
'suite_name' => [], |
|
38
|
|
|
]]); |
|
39
|
|
|
|
|
40
|
|
|
$suiteRegistryDefinition = $this->container->findDefinition('sylius_fixtures.suite_registry'); |
|
|
|
|
|
|
41
|
|
|
$suiteMethodCall = $suiteRegistryDefinition->getMethodCalls()[0]; |
|
42
|
|
|
|
|
43
|
|
|
static::assertSame('addSuite', $suiteMethodCall[0]); |
|
44
|
|
|
static::assertSame('suite_name', $suiteMethodCall[1][0]); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @test |
|
49
|
|
|
*/ |
|
50
|
|
|
public function it_processes_parameters_below_options_node() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->setParameter('fixture_parameter', '4.76'); |
|
53
|
|
|
|
|
54
|
|
|
$this->setDefinition('sylius_fixtures.suite_registry', new Definition()); |
|
55
|
|
|
|
|
56
|
|
|
$this->load(['suites' => [ |
|
57
|
|
|
'suite_name' => [ |
|
58
|
|
|
'fixtures' => [ |
|
59
|
|
|
'fixture' => [ |
|
60
|
|
|
'options' => [ |
|
61
|
|
|
'option' => '%fixture_parameter%', |
|
62
|
|
|
], |
|
63
|
|
|
], |
|
64
|
|
|
], |
|
65
|
|
|
], |
|
66
|
|
|
]]); |
|
67
|
|
|
|
|
68
|
|
|
$this->compile(); |
|
69
|
|
|
|
|
70
|
|
|
$suiteRegistryDefinition = $this->container->findDefinition('sylius_fixtures.suite_registry'); |
|
|
|
|
|
|
71
|
|
|
$suiteMethodCallArguments = $suiteRegistryDefinition->getMethodCalls()[0][1]; |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
static::assertSame('4.76', $suiteMethodCallArguments[1]['fixtures']['fixture']['options'][0]['option']); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* {@inheritdoc} |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function getContainerExtensions() |
|
80
|
|
|
{ |
|
81
|
|
|
return [new SyliusFixturesExtension()]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.