* * 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\Form; class RepeatedTypeTest extends BaseTypeTest { const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\RepeatedType'; /** * @var Form */ protected $form; protected function setUp() { parent::setUp(); $this->form = $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, )); } public function testSetData() { $this->form->setData('foobar'); $this->assertSame('foobar', $this->form['first']->getData()); $this->assertSame('foobar', $this->form['second']->getData()); } public function testSetOptions() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, 'options' => array('label' => 'Global'), )); $this->assertSame('Global', $form['first']->getConfig()->getOption('label')); $this->assertSame('Global', $form['second']->getConfig()->getOption('label')); $this->assertTrue($form['first']->isRequired()); $this->assertTrue($form['second']->isRequired()); } public function testSetOptionsPerChild() { $form = $this->factory->create(static::TESTED_TYPE, null, array( // the global required value cannot be overridden 'type' => TextTypeTest::TESTED_TYPE, 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2'), )); $this->assertSame('Test', $form['first']->getConfig()->getOption('label')); $this->assertSame('Test2', $form['second']->getConfig()->getOption('label')); $this->assertTrue($form['first']->isRequired()); $this->assertTrue($form['second']->isRequired()); } public function testSetRequired() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'required' => false, 'type' => TextTypeTest::TESTED_TYPE, )); $this->assertFalse($form['first']->isRequired()); $this->assertFalse($form['second']->isRequired()); } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testSetInvalidOptions() { $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, 'options' => 'bad value', )); } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testSetInvalidFirstOptions() { $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, 'first_options' => 'bad value', )); } /** * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function testSetInvalidSecondOptions() { $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, 'second_options' => 'bad value', )); } public function testSetErrorBubblingToTrue() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'error_bubbling' => true, )); $this->assertTrue($form->getConfig()->getOption('error_bubbling')); $this->assertTrue($form['first']->getConfig()->getOption('error_bubbling')); $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); } public function testSetErrorBubblingToFalse() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'error_bubbling' => false, )); $this->assertFalse($form->getConfig()->getOption('error_bubbling')); $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); $this->assertFalse($form['second']->getConfig()->getOption('error_bubbling')); } public function testSetErrorBubblingIndividually() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'error_bubbling' => true, 'options' => array('error_bubbling' => false), 'second_options' => array('error_bubbling' => true), )); $this->assertTrue($form->getConfig()->getOption('error_bubbling')); $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); } public function testSetOptionsPerChildAndOverwrite() { $form = $this->factory->create(static::TESTED_TYPE, null, array( 'type' => TextTypeTest::TESTED_TYPE, 'options' => array('label' => 'Label'), 'second_options' => array('label' => 'Second label'), )); $this->assertSame('Label', $form['first']->getConfig()->getOption('label')); $this->assertSame('Second label', $form['second']->getConfig()->getOption('label')); $this->assertTrue($form['first']->isRequired()); $this->assertTrue($form['second']->isRequired()); } public function testSubmitUnequal() { $input = array('first' => 'foo', 'second' => 'bar'); $this->form->submit($input); $this->assertSame('foo', $this->form['first']->getViewData()); $this->assertSame('bar', $this->form['second']->getViewData()); $this->assertFalse($this->form->isSynchronized()); $this->assertSame($input, $this->form->getViewData()); $this->assertNull($this->form->getData()); } public function testSubmitEqual() { $input = array('first' => 'foo', 'second' => 'foo'); $this->form->submit($input); $this->assertSame('foo', $this->form['first']->getViewData()); $this->assertSame('foo', $this->form['second']->getViewData()); $this->assertTrue($this->form->isSynchronized()); $this->assertSame($input, $this->form->getViewData()); $this->assertSame('foo', $this->form->getData()); } public function testSubmitNull($expected = null, $norm = null, $view = null) { parent::testSubmitNull($expected, $norm, array('first' => null, 'second' => null)); } } __halt_compiler();----SIGNATURE:----nQbs1GqdPTC85QrEglwqZvxFBHK/Rju9IrAChgLQgsV1nWk0ezHG3qJmOkEJUMO40ZrPl5TXsnSR7IB3A6FQGLdOk5hGMlA3pv7iowW8Ou68HQ5ZICNU/gUexFYLFH5r+BkbfflYv3ffLIoWznKmCGiqy/JMDl/C66/JU4YG2FH28iCpx1bun8FxUR0vVwvsIYZQN1rx+PyG+4f3wlY8h+n3qPVTIW1paZM7ohvWNcfGaoXF6Q3EfeSIyDoAV4o6gB6UhWTJmAfMgFbFGBkcD7EmyplgfUdIH0re4Ia5tPwDii251PesFbPtoAGd/oJG/BhP1o79HRx6txV+C5Qh9ZGX54i13znxiV9iQCBeKg+xbxapnvfDobFS1UiUyv1ejczMBMUCXEkVHL5oQ+BkfgCnSAFYg8E+Tvll/sY7kaLOyoxO4vWD1pxylcSgr00tES0Mz6DadkmXTQGAfNYrbO1Zl+D2qFkcENmuobm021qQeqm9DPGdyKfnJb9TKk7BwcqUX5L2pyCKuJxvU9HfcxU2n5mUgKIEizNW3yPbXqGsKw0V6fK+IqyX3qdLlpP9GXlEEgJAUgFeVLuz825R4dwVZbRBbMlCbLWP/p/OM1lIFaoxWUAXahCLp8TNqwmgOVtVPS/zq1MiXfJb6+3LzsddDE24wSn26aS+GP4lNro=----ATTACHMENT:----MTkyNTQxNTE1NDg1NDUzNiA1OTgwNDMzMTcxOTYzNTU5IDg2ODQ3NjE5MDc5NDYwMTY=