Completed
Push — master ( e207d9...c74d35 )
by Eric
09:33
created

IvoryFormExtraExtensionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Ivory Form Extra package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\FormExtraBundle\Tests\DependencyInjection;
13
14
use Ivory\FormExtraBundle\DependencyInjection\IvoryFormExtraExtension;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Ivory Form Javascript extension test.
19
 *
20
 * @author GeLo <[email protected]>
21
 */
22
class IvoryFormExtraExtensionTest extends \PHPUnit_Framework_TestCase
23
{
24
    /** @var \Symfony\Component\DependencyInjection\ContainerBuilder */
25
    private $container;
26
27
    /** @var \Symfony\Component\Form\FormRendererInterface|\PHPUnit_Framework_MockObject_MockObject */
28
    private $formRendererMock;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function setUp()
34
    {
35
        $this->formRendererMock = $this->getMock('Symfony\Component\Form\FormRendererInterface');
36
37
        $this->container = new ContainerBuilder();
38
        $this->container->set('templating.form.renderer', $this->formRendererMock);
39
        $this->container->set('twig.form.renderer', $this->formRendererMock);
40
41
        $this->container->registerExtension($extension = new IvoryFormExtraExtension());
42
        $this->container->loadFromExtension($extension->getAlias());
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    protected function tearDown()
49
    {
50
        unset($this->container);
51
    }
52
53
    public function testTemplatingHelper()
54
    {
55
        $this->container->compile();
56
57
        $this->assertTrue($this->container->hasDefinition($helper = 'ivory_form_extra.templating.helper'));
58
        $this->assertTrue($this->container->getDefinition($helper)->hasTag($tag = 'templating.helper'));
59
60
        $this->assertSame(
61
            array(array('alias' => 'ivory_form_extra')),
62
            $this->container->getDefinition($helper)->getTag($tag)
63
        );
64
65
        $this->assertInstanceOf('Ivory\FormExtraBundle\Templating\FormExtraHelper', $this->container->get($helper));
66
    }
67
68
    public function testTwigExtension()
69
    {
70
        $this->container->compile();
71
72
        $this->assertTrue($this->container->hasDefinition($helper = 'ivory_form_extra.twig.extension'));
73
        $this->assertTrue($this->container->getDefinition($helper)->hasTag($tag = 'twig.extension'));
74
        $this->assertInstanceOf('Ivory\FormExtraBundle\Twig\FormExtraExtension', $this->container->get($helper));
75
    }
76
}
77