1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Meup TagCommander Bundle. |
5
|
|
|
* |
6
|
|
|
* (c) 1001pharmacies <http://github.com/1001pharmacies/tagcommander-bundle> |
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 Meup\Bundle\TagcommanderBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
15
|
|
|
use Meup\Bundle\TagcommanderBundle\DependencyInjection\MeupTagcommanderExtension; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* |
19
|
|
|
*/ |
20
|
|
|
class MeupTagcommanderExtensionTest extends \PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var MeupTagcommanderExtension |
24
|
|
|
*/ |
25
|
|
|
private $extension; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Root name of the configuration |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $root; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return MeupTagcommanderExtension |
36
|
|
|
*/ |
37
|
|
|
protected function getExtension() |
38
|
|
|
{ |
39
|
|
|
return new MeupTagcommanderExtension(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return ContainerBuilder |
44
|
|
|
*/ |
45
|
|
|
private function getContainer() |
46
|
|
|
{ |
47
|
|
|
$container = new ContainerBuilder(); |
48
|
|
|
|
49
|
|
|
return $container; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* |
54
|
|
|
*/ |
55
|
|
|
public function setUp() |
56
|
|
|
{ |
57
|
|
|
parent::setUp(); |
58
|
|
|
|
59
|
|
|
$this->extension = $this->getExtension(); |
60
|
|
|
$this->root = 'meup_tagcommander'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* |
65
|
|
|
*/ |
66
|
|
|
public function testGetConfigWithDefaultValues() |
67
|
|
|
{ |
68
|
|
|
|
69
|
|
|
$configs = array( |
70
|
|
|
'default_event' => 'default', |
71
|
|
|
'datalayer' => array( |
72
|
|
|
'name' => 'tc_vars', |
73
|
|
|
'default' => array( |
74
|
|
|
'env' => '%kernel.environment%', |
75
|
|
|
'locale' => '%locale%', |
76
|
|
|
), |
77
|
|
|
), |
78
|
|
|
'containers' => array( |
79
|
|
|
array( |
80
|
|
|
'name' => 'ab-test', |
81
|
|
|
'script' => 'my-ab-test-container.js', |
82
|
|
|
), |
83
|
|
|
array( |
84
|
|
|
'name' => 'generic', |
85
|
|
|
'script' => 'my-generic-container.js', |
86
|
|
|
'version' => 'v17.11', |
87
|
|
|
'alternative' => '//redirect1578.tagcommander.com/utils/noscript.php?id=3&mode=iframe', |
88
|
|
|
), |
89
|
|
|
), |
90
|
|
|
'events' => array( |
91
|
|
|
array( |
92
|
|
|
'name' => 'default', |
93
|
|
|
'function' => 'tc_events_1', |
94
|
|
|
), |
95
|
|
|
array( |
96
|
|
|
'name' => 'other_events', |
97
|
|
|
'function' => 'tc_events_2', |
98
|
|
|
), |
99
|
|
|
), |
100
|
|
|
); |
101
|
|
|
|
102
|
|
|
$this |
103
|
|
|
->extension |
104
|
|
|
->load( |
105
|
|
|
array($configs), |
106
|
|
|
$container = $this->getContainer() |
107
|
|
|
) |
108
|
|
|
; |
109
|
|
|
|
110
|
|
|
$this->assertTrue($container->hasDefinition($this->root.'.datalayer')); |
111
|
|
|
$this->assertTrue($container->hasDefinition($this->root.'.twig_extension')); |
112
|
|
|
$this->assertTrue($container->hasDefinition($this->root.'.datacollector_subscriber')); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|