]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php
a1292dbe72287520d24a5d5758a863457b6fcac9
[github/wallabag/wallabag.git] / vendor / symfony / form / Symfony / Component / Form / Tests / FormFactoryBuilderTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Form\Tests;
13
14 use Symfony\Component\Form\FormFactoryBuilder;
15 use Symfony\Component\Form\Tests\Fixtures\FooType;
16
17 class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase
18 {
19 private $registry;
20 private $guesser;
21 private $type;
22
23 protected function setUp()
24 {
25 $factory = new \ReflectionClass('Symfony\Component\Form\FormFactory');
26 $this->registry = $factory->getProperty('registry');
27 $this->registry->setAccessible(true);
28
29 $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
30 $this->type = new FooType;
31 }
32
33 public function testAddType()
34 {
35 $factoryBuilder = new FormFactoryBuilder;
36 $factoryBuilder->addType($this->type);
37
38 $factory = $factoryBuilder->getFormFactory();
39 $registry = $this->registry->getValue($factory);
40 $extensions = $registry->getExtensions();
41
42 $this->assertCount(1, $extensions);
43 $this->assertTrue($extensions[0]->hasType($this->type->getName()));
44 $this->assertNull($extensions[0]->getTypeGuesser());
45 }
46
47 public function testAddTypeGuesser()
48 {
49 $factoryBuilder = new FormFactoryBuilder;
50 $factoryBuilder->addTypeGuesser($this->guesser);
51
52 $factory = $factoryBuilder->getFormFactory();
53 $registry = $this->registry->getValue($factory);
54 $extensions = $registry->getExtensions();
55
56 $this->assertCount(1, $extensions);
57 $this->assertNotNull($extensions[0]->getTypeGuesser());
58 }
59 }