Completed
Push — master ( 081637...206e0a )
by Eric
06:26
created

IconFormExtensionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Lug 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 Lug\Bundle\UiBundle\Tests\Form\Extension;
13
14
use Lug\Bundle\UiBundle\Form\Extension\IconFormExtension;
15
use Symfony\Component\Form\Extension\Core\Type\FormType;
16
use Symfony\Component\Form\FormFactoryInterface;
17
use Symfony\Component\Form\Forms;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class IconFormExtensionTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * @var FormFactoryInterface
26
     */
27
    private $factory;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    protected function setUp()
33
    {
34
        $this->factory = Forms::createFormFactoryBuilder()
35
            ->addTypeExtension(new IconFormExtension())
36
            ->getFormFactory();
37
    }
38
39
    public function testDefault()
40
    {
41
        $form = $this->factory->create(FormType::class);
42
        $view = $form->createView();
43
44
        $this->assertArrayHasKey('icon', $view->vars);
45
        $this->assertNull($view->vars['icon']);
46
    }
47
48
    public function testIcon()
49
    {
50
        $form = $this->factory->create(FormType::class, null, ['icon' => $icon = 'my.icon']);
51
        $view = $form->createView();
52
53
        $this->assertArrayHasKey('icon', $view->vars);
54
        $this->assertSame($icon, $view->vars['icon']);
55
    }
56
}
57