|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Evheniy\HTML5VertiTemplateBundle\Tests\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
6
|
|
|
use Symfony\Component\Config\FileLocator; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
8
|
|
|
use Evheniy\HTML5VertiTemplateBundle\DependencyInjection\HTML5VertiTemplateExtension; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class HTML5VertiTemplateExtensionTest |
|
12
|
|
|
* |
|
13
|
|
|
* @package Evheniy\HTML5VertiTemplateBundle\Tests\DependencyInjection |
|
14
|
|
|
*/ |
|
15
|
|
|
class HTML5VertiTemplateExtensionTest extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var HTML5VertiTemplateExtensionTest |
|
19
|
|
|
*/ |
|
20
|
|
|
private $extension; |
|
21
|
|
|
/** |
|
22
|
|
|
* @var ContainerBuilder |
|
23
|
|
|
*/ |
|
24
|
|
|
private $container; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* |
|
28
|
|
|
*/ |
|
29
|
|
|
protected function setUp() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->extension = new HTML5VertiTemplateExtension(); |
|
32
|
|
|
|
|
33
|
|
|
$this->container = new ContainerBuilder(); |
|
34
|
|
|
$this->container->registerExtension($this->extension); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param ContainerBuilder $container |
|
39
|
|
|
* @param string $resource |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function loadConfiguration(ContainerBuilder $container, $resource) |
|
42
|
|
|
{ |
|
43
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/Fixtures/')); |
|
44
|
|
|
$loader->load($resource . '.yml'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Test empty config |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testWithoutConfiguration() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->container->loadFromExtension($this->extension->getAlias()); |
|
53
|
|
|
$this->container->compile(); |
|
54
|
|
|
$this->assertTrue($this->container->hasParameter('html5_verti_template')); |
|
55
|
|
|
$html5VertiTemplate = $this->container->getParameter('html5_verti_template'); |
|
56
|
|
|
$this->assertNotEmpty($html5VertiTemplate); |
|
57
|
|
|
$this->assertTrue(is_array($html5VertiTemplate)); |
|
58
|
|
|
$this->assertEmpty($html5VertiTemplate['cdn']); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Test normal config |
|
63
|
|
|
*/ |
|
64
|
|
|
public function testTest() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->loadConfiguration($this->container, 'test'); |
|
67
|
|
|
$this->container->compile(); |
|
68
|
|
|
$this->assertTrue($this->container->hasParameter('html5_verti_template')); |
|
69
|
|
|
$html5VertiTemplate = $this->container->getParameter('html5_verti_template'); |
|
70
|
|
|
$this->assertNotEmpty($html5VertiTemplate['cdn']); |
|
71
|
|
|
$this->assertEquals($html5VertiTemplate['cdn'], '//cdn.site.com'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* |
|
76
|
|
|
*/ |
|
77
|
|
|
public function testGetAlias() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->assertEquals($this->extension->getAlias(), 'html5_verti_template'); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|