1
|
|
|
<?php |
2
|
|
|
namespace OnurbTest\Bundle\YumlBundle\DependencyInjection; |
3
|
|
|
|
4
|
|
|
use Onurb\Bundle\YumlBundle\DependencyInjection\OnurbYumlExtension; |
5
|
|
|
use Symfony\Component\Config\FileLocator; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
7
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
8
|
|
|
|
9
|
|
|
abstract class AbstractOnurbYumlExtensionTest extends \PHPUnit_Framework_TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var OnurbYumlExtension |
13
|
|
|
*/ |
14
|
|
|
private $extension; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var ContainerBuilder |
18
|
|
|
*/ |
19
|
|
|
private $container; |
20
|
|
|
|
21
|
|
|
protected function setUp() |
22
|
|
|
{ |
23
|
|
|
$this->extension = new OnurbYumlExtension(); |
24
|
|
|
$this->container = new ContainerBuilder(); |
25
|
|
|
|
26
|
|
|
$this->container->registerExtension($this->extension); |
27
|
|
|
|
28
|
|
|
$loader = new Loader\YamlFileLoader($this->container, new FileLocator(__DIR__ . '/Fixtures/')); |
29
|
|
|
$loader->load('fake_doctrine_service.yml'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
abstract protected function loadConfiguration(ContainerBuilder $container, $resource); |
33
|
|
|
|
34
|
|
|
public function testDefaultConfiguration() |
35
|
|
|
{ |
36
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
37
|
|
|
$this->container->compile(); |
38
|
|
|
|
39
|
|
|
$this->assertFalse($this->container->has('onurb_yuml')); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testDefaultParams() |
43
|
|
|
{ |
44
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
45
|
|
|
$this->container->compile(); |
46
|
|
|
|
47
|
|
|
$this->assertFalse($this->container->getParameter('onurb_yuml.show_fields_description')); |
48
|
|
|
|
49
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.colors')); |
50
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.notes')); |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testTrueConfiguration() |
55
|
|
|
{ |
56
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
57
|
|
|
$this->loadConfiguration($this->container, 'config_true'); |
58
|
|
|
$this->container->compile(); |
59
|
|
|
|
60
|
|
|
$this->assertTrue($this->container->getParameter('onurb_yuml.show_fields_description')); |
61
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.colors')); |
62
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.notes')); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testPartialConfiguration() |
66
|
|
|
{ |
67
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
68
|
|
|
|
69
|
|
|
$this->loadConfiguration($this->container, 'config_partial'); |
70
|
|
|
$this->container->compile(); |
71
|
|
|
|
72
|
|
|
$this->assertTrue($this->container->getParameter('onurb_yuml.show_fields_description')); |
73
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.colors')); |
74
|
|
|
$this->assertSame(array(), $this->container->getParameter('onurb_yuml.notes')); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function testArrayColorsConfiguration() |
78
|
|
|
{ |
79
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
80
|
|
|
|
81
|
|
|
$this->loadConfiguration($this->container, 'config_colors'); |
82
|
|
|
$this->container->compile(); |
83
|
|
|
|
84
|
|
|
$this->assertSame( |
85
|
|
|
array( |
86
|
|
|
'My\Class' => 'green', |
87
|
|
|
'My\OtherClass' => 'blue' |
88
|
|
|
), |
89
|
|
|
$this->container->getParameter('onurb_yuml.colors') |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
public function testArrayNotesConfiguration() |
93
|
|
|
{ |
94
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
95
|
|
|
|
96
|
|
|
$this->loadConfiguration($this->container, 'config_notes'); |
97
|
|
|
$this->container->compile(); |
98
|
|
|
|
99
|
|
|
$this->assertSame( |
100
|
|
|
array( |
101
|
|
|
'My\Class' => 'My note', |
102
|
|
|
'My\OtherClass' => 'My other note' |
103
|
|
|
), |
104
|
|
|
$this->container->getParameter('onurb_yuml.notes') |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|