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
|
|
|
|