1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Basster\LegacyBridgeBundle\Tests\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Basster\LegacyBridgeBundle\DependencyInjection\Configuration; |
6
|
|
|
use Symfony\Component\Config\Definition\ArrayNode; |
7
|
|
|
|
8
|
|
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
/** @var ArrayNode */ |
11
|
|
|
private $tree; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @test |
15
|
|
|
*/ |
16
|
|
|
public function hasRootName() |
17
|
|
|
{ |
18
|
|
|
self::assertEquals('basster_legacy_bridge', $this->tree->getName()); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @test |
23
|
|
|
*/ |
24
|
|
|
public function hasLegacyPathNodeWithDefaultValue() |
25
|
|
|
{ |
26
|
|
|
$legacyPathNode = $this->getChildNode('legacy_path'); |
27
|
|
|
|
28
|
|
|
self::assertEquals( |
29
|
|
|
'/path/to/my/legacy/project/files', |
30
|
|
|
$legacyPathNode->getDefaultValue() |
31
|
|
|
); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param $nodeName |
36
|
|
|
* |
37
|
|
|
* @return \Symfony\Component\Config\Definition\ArrayNode |
38
|
|
|
*/ |
39
|
|
|
private function getChildNode($nodeName) |
40
|
|
|
{ |
41
|
|
|
/** @var ArrayNode[] $childs */ |
42
|
|
|
$childs = $this->tree->getChildren(); |
43
|
|
|
|
44
|
|
|
self::assertArrayHasKey($nodeName, $childs); |
45
|
|
|
|
46
|
|
|
return $childs[$nodeName]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @test |
51
|
|
|
* @dataProvider provideNullDefaultNodes |
52
|
|
|
*/ |
53
|
|
|
public function hasAppendScriptNodeWithDefaultNull($nodeName) |
54
|
|
|
{ |
55
|
|
|
$appendScriptNode = $this->getChildNode($nodeName); |
56
|
|
|
|
57
|
|
|
self::assertNull($appendScriptNode->getDefaultValue()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function provideNullDefaultNodes() |
61
|
|
|
{ |
62
|
|
|
return array( |
63
|
|
|
'append_script' => array('append_script'), |
64
|
|
|
'prepend_script' => array('prepend_script'), |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected function setUp() |
69
|
|
|
{ |
70
|
|
|
$config = new Configuration(); |
71
|
|
|
$treeBuilder = $config->getConfigTreeBuilder(); |
72
|
|
|
$this->tree = $treeBuilder->buildTree(); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|