* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\Test\TypeTestCase; /** * @author Bernhard Schussek */ abstract class BaseTypeTest extends TypeTestCase { const TESTED_TYPE = ''; public function testPassDisabledAsOption() { $form = $this->factory->create($this->getTestedType(), null, array('disabled' => true)); $this->assertTrue($form->isDisabled()); } public function testPassIdAndNameToView() { $view = $this->factory->createNamed('name', $this->getTestedType()) ->createView(); $this->assertEquals('name', $view->vars['id']); $this->assertEquals('name', $view->vars['name']); $this->assertEquals('name', $view->vars['full_name']); } public function testStripLeadingUnderscoresAndDigitsFromId() { $view = $this->factory->createNamed('_09name', $this->getTestedType()) ->createView(); $this->assertEquals('name', $view->vars['id']); $this->assertEquals('_09name', $view->vars['name']); $this->assertEquals('_09name', $view->vars['full_name']); } public function testPassIdAndNameToViewWithParent() { $view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', $this->getTestedType()) ->getForm() ->createView(); $this->assertEquals('parent_child', $view['child']->vars['id']); $this->assertEquals('child', $view['child']->vars['name']); $this->assertEquals('parent[child]', $view['child']->vars['full_name']); } public function testPassIdAndNameToViewWithGrandParent() { $builder = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', FormTypeTest::TESTED_TYPE); $builder->get('child')->add('grand_child', $this->getTestedType()); $view = $builder->getForm()->createView(); $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); $this->assertEquals('grand_child', $view['child']['grand_child']->vars['name']); $this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->vars['full_name']); } public function testPassTranslationDomainToView() { $view = $this->factory->create($this->getTestedType(), null, array( 'translation_domain' => 'domain', )) ->createView(); $this->assertSame('domain', $view->vars['translation_domain']); } public function testInheritTranslationDomainFromParent() { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( 'translation_domain' => 'domain', )) ->add('child', $this->getTestedType()) ->getForm() ->createView(); $this->assertEquals('domain', $view['child']->vars['translation_domain']); } public function testPreferOwnTranslationDomain() { $view = $this->factory ->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE, null, array( 'translation_domain' => 'parent_domain', )) ->add('child', $this->getTestedType(), array( 'translation_domain' => 'domain', )) ->getForm() ->createView(); $this->assertEquals('domain', $view['child']->vars['translation_domain']); } public function testDefaultTranslationDomain() { $view = $this->factory->createNamedBuilder('parent', FormTypeTest::TESTED_TYPE) ->add('child', $this->getTestedType()) ->getForm() ->createView(); $this->assertNull($view['child']->vars['translation_domain']); } public function testPassLabelToView() { $view = $this->factory->createNamed('__test___field', $this->getTestedType(), null, array('label' => 'My label')) ->createView(); $this->assertSame('My label', $view->vars['label']); } public function testPassMultipartFalseToView() { $view = $this->factory->create($this->getTestedType()) ->createView(); $this->assertFalse($view->vars['multipart']); } public function testSubmitNull($expected = null, $norm = null, $view = null) { $form = $this->factory->create($this->getTestedType()); $form->submit(null); $this->assertSame($expected, $form->getData()); $this->assertSame($norm, $form->getNormData()); $this->assertSame($view, $form->getViewData()); } protected function getTestedType() { return static::TESTED_TYPE; } } __halt_compiler();----SIGNATURE:----e4lTio7A9WCSx7Ll97acew4BwZ4uaEojPgwSdc0JkE9QvyUr+qnGpRdZiffVrdMepabytTEiRTrD+t+7j/2U0IKG1ZhkkFCqp/tc6SeK7pdUBpwTwx5xW1IHtAsR7IIfycUlW9BNdfAJ+mq0pP8qf/InzeOQiRE3UcIvAPIIFN3LDqTyl8M1WzMHk0nUDo03rSBLY8gEArj8oohNE7R8GsYNozjSowUIB9U/cz0QZQWZ44+mqF5656Sj89UOSDyEthdQA7RByoc8NzW9HnrXtP5kEZo3defAp7P7MfE9vAetjbYxqUdMssIpJ4sotcgGAFvwpYawh9hJ+HZTWsqOSuD3sWQVVTG32ZIB8ewwoC53mxiRHsXzQfjbkkOTURl6IY0O6hlBe8mFs2SMj/aJrYdqz0jSxNz68Mt4VX94PncyqoLgpcrf0TJhYyfZ9YqNhU/JMs6ADeLQpqPD7+md0ToUHm2KO2L0OhwMae+5j114cdm2EA4fQ+TzIuOOQoXiHKEjiAFMYUflRYHWoz8qOH6oe+3C+Z4UYv4Gfh8LNnB4HeyY6chy9Ua7hWavV7P5DDHYHVzLk3TprV7KxgET+tO7LIS+IzXud6hBKMFse/OqB6xCK53a1VGZqT/Y3mb5fzlHEb+Y5mqoJKhYvvD/V16aY5DFiEGd96WKfwOYS6U=----ATTACHMENT:----NTQzODk3MjExNDk5MzUyNCA3MzQwNTgyOTMwNzc0MTI0IDU3MjM1MzU3NjUxMzU5NTI=