HTML5VertiTemplateExtensionTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Evheniy\HTML5VertiTemplateBundle\Tests\Twig;
4
5
use Evheniy\HTML5VertiTemplateBundle\Twig\HTML5VertiTemplateExtension;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * Class HTML5VertiTemplateExtensionTest
10
 *
11
 * @package Evheniy\HTML5VertiTemplateBundle\Tests\Twig
12
 */
13
class HTML5VertiTemplateExtensionTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * @var HTML5VertiTemplateExtension
17
     */
18
    private $extension;
19
    /**
20
     * @var ContainerBuilder
21
     */
22
    private $container;
23
24
    /**
25
     *
26
     */
27
    protected function setUp()
28
    {
29
        $this->container = new ContainerBuilder();
30
        $this->extension = new HTML5VertiTemplateExtension($this->container);
31
    }
32
33
    /**
34
     * Test normal config
35
     */
36
    public function testWithCDN()
37
    {
38
        $this->container->setParameter('html5_verti_template', array('cdn' => 'test'));
39
        $this->assertTrue($this->container->hasParameter('html5_verti_template'));
40
        $html5VertiTemplate = $this->container->getParameter('html5_verti_template');
41
        $this->assertNotEmpty($html5VertiTemplate['cdn']);
42
        $this->assertEquals($html5VertiTemplate['cdn'], 'test');
43
        $globals = $this->extension->getGlobals();
44
        $html5VertiTemplate = $globals['html5_verti_template'];
45
        $this->assertNotEmpty($html5VertiTemplate['cdn']);
46
        $this->assertEquals($html5VertiTemplate['cdn'], 'test');
47
    }
48
49
    /**
50
     * Test empty config
51
     */
52
    public function testWithOutData()
53
    {
54
        $this->assertFalse($this->container->hasParameter('html5_verti_template'));
55
        $this->setExpectedException(
56
            'Exception',
57
            'You have requested a non-existent parameter "html5_verti_template".'
58
        );
59
        $this->assertEmpty($this->extension->getGlobals());
60
    }
61
62
    /**
63
     * Test getName()
64
     */
65
    public function testGetName()
66
    {
67
        $this->assertEquals($this->extension->getName(), 'html5_verti_template');
68
    }
69
}