4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Tests
;
14 use Symfony\Component\Form\FormFactoryBuilder
;
15 use Symfony\Component\Form\Tests\Fixtures\FooType
;
17 class FormFactoryBuilderTest
extends \PHPUnit_Framework_TestCase
23 protected function setUp()
25 $factory = new \
ReflectionClass('Symfony\Component\Form\FormFactory');
26 $this->registry
= $factory->getProperty('registry');
27 $this->registry
->setAccessible(true);
29 $this->guesser
= $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
30 $this->type
= new FooType
;
33 public function testAddType()
35 $factoryBuilder = new FormFactoryBuilder
;
36 $factoryBuilder->addType($this->type
);
38 $factory = $factoryBuilder->getFormFactory();
39 $registry = $this->registry
->getValue($factory);
40 $extensions = $registry->getExtensions();
42 $this->assertCount(1, $extensions);
43 $this->assertTrue($extensions[0]->hasType($this->type
->getName()));
44 $this->assertNull($extensions[0]->getTypeGuesser());
47 public function testAddTypeGuesser()
49 $factoryBuilder = new FormFactoryBuilder
;
50 $factoryBuilder->addTypeGuesser($this->guesser
);
52 $factory = $factoryBuilder->getFormFactory();
53 $registry = $this->registry
->getValue($factory);
54 $extensions = $registry->getExtensions();
56 $this->assertCount(1, $extensions);
57 $this->assertNotNull($extensions[0]->getTypeGuesser());