* * 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:----soMWJWl94gCyoQ6i71ZrngnqPkgo6S59+csXzar40CTmXzEizTlGPRlEFiRHjQnMMs5WKg0Q+R4ZmCinFc+5K5fNPzdiFgL2Dx+bep4GiGbjgcI5Gs8IV0D9OquYcda7/BksjbPxnnnfbPz1iEUEIBWad4povnysccwGd8IrnjkeZVdz9VhnkzNCIwf13pQAfP3IeAmZU6+p1xErbVXUsosSy00/AUGAPQxiTMzTOx5ruB4eQh/tz1hW2N/7w7jIUel64Ntw2GcLvOREKWGSCVAVNf/RK1b3CgigSQnXCCHV2kvJkXD4899CkZQL5JPn3aHjAVxaJKk6UNrIki6LRK1Js07xnYdaB3B4FD+r0WgRpZoAYG/KC2odUL9oHoQtXYsJe5oQFYlRKCui7HwR1dHMAqP8cNhGNIB5UmXeDOkUkB+O3djKd+k2whrovMpFH5CKrbwuHni71hiwzs7zZt4f384+2Wmf2522CJ6y9EzAd0vddeeVGlx3Tq6DjyC9rgt4vhjwOqIXaVLhIY0rotlx1WDsmncV5wlNI6y03QfF4meSa8pfmnvLE2g3vwU88VpoD1J5t6BaApNWCjzGSeSUDvRgekmC+Q7+BVy//EDHTztpvl3bRg12MyEcGPMUy7mJU3gcOjVyWBuViP2B+bjB3+50FrjTCtjVqcDJCb4=----ATTACHMENT:----NTg2ODY5NDI1ODE4MDQ0OSAxNTUzNjYxMjcyMzEwODk4IDY0OTUwNTE1NTkxNzYxNjc=