From 877d8f71954fff70b98383235086dd116dc1daaf Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Wed, 23 May 2012 21:50:13 +0200 Subject: [PATCH] [Form] Reversed the order of $type and $name in FormFactory::createNamed[Builder]() --- UPGRADE-2.1.md | 17 ++ .../Tests/Form/Type/EntityTypeTest.php | 56 +++--- .../Extension/FormExtensionDivLayoutTest.php | 4 +- src/Symfony/Component/Form/CHANGELOG.md | 2 + .../Core/EventListener/ResizeFormListener.php | 4 +- .../Csrf/Type/FormTypeCsrfExtension.php | 2 +- src/Symfony/Component/Form/FormBuilder.php | 2 +- src/Symfony/Component/Form/FormFactory.php | 11 +- .../Component/Form/FormFactoryInterface.php | 8 +- .../Form/Tests/AbstractDivLayoutTest.php | 50 +++--- .../Form/Tests/AbstractLayoutTest.php | 164 +++++++++--------- .../Form/Tests/AbstractTableLayoutTest.php | 28 +-- .../EventListener/ResizeFormListenerTest.php | 6 +- .../Extension/Core/Type/ChoiceTypeTest.php | 4 +- .../Extension/Core/Type/FormTypeTest.php | 58 +++---- .../Csrf/Type/FormTypeCsrfExtensionTest.php | 4 +- .../Component/Form/Tests/FormBuilderTest.php | 8 +- .../Component/Form/Tests/FormFactoryTest.php | 46 ++--- src/Symfony/Component/Form/Tests/FormTest.php | 2 +- 19 files changed, 247 insertions(+), 229 deletions(-) diff --git a/UPGRADE-2.1.md b/UPGRADE-2.1.md index 509e8f503f..236aa76419 100644 --- a/UPGRADE-2.1.md +++ b/UPGRADE-2.1.md @@ -700,6 +700,23 @@ }); ``` + * The order of the first two arguments of the methods `createNamed` and + `createNamedBuilder` in `FormFactoryInterface` was reversed to match with + the rest of the component. You should scan your code for occurrences of + these methods and reverse the parameters. + + Before: + + ``` + $form = $factory->createNamed('text', 'firstName'); + ``` + + After: + + ``` + $form = $factory->createNamed('firstName', 'text'); + ``` + ### Validator * The methods `setMessage()`, `getMessageTemplate()` and diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index d7a2f11069..123f7178ec 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -108,7 +108,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, @@ -125,7 +125,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, @@ -142,7 +142,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); $qb = $this->em->createQueryBuilder()->select('e')->from(self::SINGLE_IDENT_CLASS, 'e'); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, @@ -158,7 +158,7 @@ class EntityTypeTest extends TypeTestCase */ public function testConfigureQueryBuilderWithNonQueryBuilderAndNonClosure() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => new \stdClass(), @@ -170,7 +170,7 @@ class EntityTypeTest extends TypeTestCase */ public function testConfigureQueryBuilderWithClosureReturningNonQueryBuilder() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function () { @@ -183,7 +183,7 @@ class EntityTypeTest extends TypeTestCase public function testSetDataSingleNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, @@ -196,7 +196,7 @@ class EntityTypeTest extends TypeTestCase public function testSetDataMultipleExpandedNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', @@ -210,7 +210,7 @@ class EntityTypeTest extends TypeTestCase public function testSetDataMultipleNonExpandedNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', @@ -224,7 +224,7 @@ class EntityTypeTest extends TypeTestCase public function testSubmitSingleExpandedNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => true, 'em' => 'default', @@ -238,7 +238,7 @@ class EntityTypeTest extends TypeTestCase public function testSubmitSingleNonExpandedNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', @@ -252,7 +252,7 @@ class EntityTypeTest extends TypeTestCase public function testSubmitMultipleNull() { - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, @@ -270,7 +270,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', @@ -292,7 +292,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', @@ -316,7 +316,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', @@ -341,7 +341,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', @@ -372,7 +372,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', @@ -398,7 +398,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => false, 'em' => 'default', @@ -428,7 +428,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => true, 'em' => 'default', @@ -454,7 +454,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => true, 'expanded' => true, 'em' => 'default', @@ -484,7 +484,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, // not all persisted entities should be displayed @@ -509,7 +509,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($item1, $item2, $item3, $item4)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, 'choices' => array($item1, $item2, $item3, $item4), @@ -535,7 +535,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choices' => array($entity1, $entity2), @@ -556,7 +556,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'choices' => array($entity1, $entity2), @@ -579,7 +579,7 @@ class EntityTypeTest extends TypeTestCase $repository = $this->em->getRepository(self::SINGLE_IDENT_CLASS); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => $repository->createQueryBuilder('e') @@ -601,7 +601,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'query_builder' => function ($repository) { @@ -625,7 +625,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1, $entity2, $entity3)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'em' => 'default', 'class' => self::COMPOSITE_IDENT_CLASS, 'query_builder' => function ($repository) { @@ -647,7 +647,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', @@ -668,7 +668,7 @@ class EntityTypeTest extends TypeTestCase $this->persist(array($entity1)); - $field = $this->factory->createNamed('entity', 'name', null, array( + $field = $this->factory->createNamed('name', 'entity', null, array( 'multiple' => false, 'expanded' => false, 'em' => 'default', diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index eb214a57d5..5b6e4460e8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -69,7 +69,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function testThemeBlockInheritanceUsingUse() { $view = $this->factory - ->createNamed('email', 'name') + ->createNamed('name', 'email') ->createView() ; @@ -84,7 +84,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest public function testThemeBlockInheritanceUsingExtend() { $view = $this->factory - ->createNamed('email', 'name') + ->createNamed('name', 'email') ->createView() ; diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 9aded3a847..df17af0fa5 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -131,3 +131,5 @@ CHANGELOG * FormEvents::PRE_BIND now replaces FormEvents::BIND_CLIENT_DATA * deprecated FormEvents::SET_DATA, FormEvents::BIND_CLIENT_DATA and FormEvents::BIND_NORM_DATA + * [BC BREAK] reversed the order of the first two arguments to `createNamed` + and `createNamedBuilder` in `FormFactoryInterface` diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index 97eddcf341..a953d9e215 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -90,7 +90,7 @@ class ResizeFormListener implements EventSubscriberInterface // Then add all rows again in the correct order foreach ($data as $name => $value) { - $form->add($this->factory->createNamed($this->type, $name, null, array_replace(array( + $form->add($this->factory->createNamed($name, $this->type, null, array_replace(array( 'property_path' => '['.$name.']', ), $this->options))); } @@ -122,7 +122,7 @@ class ResizeFormListener implements EventSubscriberInterface if ($this->allowAdd) { foreach ($data as $name => $value) { if (!$form->has($name)) { - $form->add($this->factory->createNamed($this->type, $name, null, array_replace(array( + $form->add($this->factory->createNamed($name, $this->type, null, array_replace(array( 'property_path' => '['.$name.']', ), $this->options))); } diff --git a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php index 29f723cdfa..408c8ece84 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php +++ b/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php @@ -65,7 +65,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension $factory = $form->getConfig()->getAttribute('csrf_factory'); $data = $options['csrf_provider']->generateCsrfToken($options['intention']); - $csrfForm = $factory->createNamed('hidden', $options['csrf_field_name'], $data, array( + $csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array( 'property_path' => false, )); diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 2dac8bab04..dd4a76ced9 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -121,7 +121,7 @@ class FormBuilder extends FormConfig implements FormBuilderInterface } if (null !== $type) { - return $this->getFormFactory()->createNamedBuilder($type, $name, null, $options, $this); + return $this->getFormFactory()->createNamedBuilder($name, $type, null, $options, $this); } return $this->getFormFactory()->createBuilderForProperty($this->getDataClass(), $name, null, $options, $this); diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index 6409c36cf7..f95fa7d173 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -117,9 +117,9 @@ class FormFactory implements FormFactoryInterface /** * {@inheritdoc} */ - public function createNamed($type, $name, $data = null, array $options = array(), FormBuilder $parent = null) + public function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null) { - return $this->createNamedBuilder($type, $name, $data, $options, $parent)->getForm(); + return $this->createNamedBuilder($name, $type, $data, $options, $parent)->getForm(); } /** @@ -137,13 +137,13 @@ class FormFactory implements FormFactoryInterface { $name = is_object($type) ? $type->getName() : $type; - return $this->createNamedBuilder($type, $name, $data, $options, $parent); + return $this->createNamedBuilder($name, $type, $data, $options, $parent); } /** * {@inheritdoc} */ - public function createNamedBuilder($type, $name, $data = null, array $options = array(), FormBuilder $parent = null) + public function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null) { if (!array_key_exists('data', $options)) { $options['data'] = $data; @@ -151,7 +151,6 @@ class FormFactory implements FormFactoryInterface $builder = null; $types = array(); - $knownOptions = array(); $optionsResolver = new OptionsResolver(); // Bottom-up determination of the type hierarchy @@ -281,7 +280,7 @@ class FormFactory implements FormFactoryInterface $options = array_merge($typeGuess->getOptions(), $options); } - return $this->createNamedBuilder($type, $property, $data, $options, $parent); + return $this->createNamedBuilder($property, $type, $data, $options, $parent); } /** diff --git a/src/Symfony/Component/Form/FormFactoryInterface.php b/src/Symfony/Component/Form/FormFactoryInterface.php index 84037527f0..73aa7ffcae 100644 --- a/src/Symfony/Component/Form/FormFactoryInterface.php +++ b/src/Symfony/Component/Form/FormFactoryInterface.php @@ -34,8 +34,8 @@ interface FormFactoryInterface * * @see createNamedBuilder() * - * @param string|FormTypeInterface $type The type of the form * @param string $name The name of the form + * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options * @param FormBuilder $parent The parent builder @@ -44,7 +44,7 @@ interface FormFactoryInterface * * @throws Exception\FormException if any given option is not applicable to the given type */ - function createNamed($type, $name, $data = null, array $options = array(), FormBuilder $parent = null); + function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null); /** * Returns a form for a property of a class. @@ -80,8 +80,8 @@ interface FormFactoryInterface /** * Returns a form builder. * - * @param string|FormTypeInterface $type The type of the form * @param string $name The name of the form + * @param string|FormTypeInterface $type The type of the form * @param mixed $data The initial data * @param array $options The options * @param FormBuilder $parent The parent builder @@ -90,7 +90,7 @@ interface FormFactoryInterface * * @throws Exception\FormException if any given option is not applicable to the given type */ - function createNamedBuilder($type, $name, $data = null, array $options = array(), FormBuilder $parent = null); + function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null); /** * Returns a form builder for a property of a class. diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index 6f0675cba5..0841f62016 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -17,7 +17,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest { public function testRow() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $form->addError(new FormError('Error!')); $view = $form->createView(); $html = $this->renderRow($view); @@ -37,7 +37,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRowOverrideVariables() { - $view = $this->factory->createNamed('text', 'name')->createView(); + $view = $this->factory->createNamed('name', 'text')->createView(); $html = $this->renderRow($view, array('label' => 'foo&bar')); $this->assertMatchesXpath($html, @@ -52,7 +52,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRepeatedRow() { - $form = $this->factory->createNamed('repeated', 'name'); + $form = $this->factory->createNamed('name', 'repeated'); $form->addError(new FormError('Error!')); $view = $form->createView(); $html = $this->renderRow($view); @@ -77,7 +77,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRest() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('field1', 'text') ->add('field2', 'repeated') ->add('field3', 'text') @@ -118,17 +118,17 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRestWithChildrenForms() { - $child1 = $this->factory->createNamedBuilder('form', 'child1') + $child1 = $this->factory->createNamedBuilder('child1', 'form') ->add('field1', 'text') ->add('field2', 'text') ->getForm(); - $child2 = $this->factory->createNamedBuilder('form', 'child2') + $child2 = $this->factory->createNamedBuilder('child2', 'form') ->add('field1', 'text') ->add('field2', 'text') ->getForm(); - $view = $this->factory->createNamedBuilder('form', 'parent') + $view = $this->factory->createNamedBuilder('parent', 'form') ->getForm() ->add($child1) ->add($child2) @@ -178,7 +178,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRestAndRepeatedWithRow() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('first', 'text') ->add('password', 'repeated') ->getForm() @@ -204,7 +204,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRestAndRepeatedWithRowPerChild() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('first', 'text') ->add('password', 'repeated') ->getForm() @@ -232,7 +232,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRestAndRepeatedWithWidgetPerChild() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('first', 'text') ->add('password', 'repeated') ->getForm() @@ -262,7 +262,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testCollection() { - $form = $this->factory->createNamed('collection', 'name', array('a', 'b'), array( + $form = $this->factory->createNamed('name', 'collection', array('a', 'b'), array( 'type' => 'text', )); @@ -279,7 +279,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testEmptyCollection() { - $form = $this->factory->createNamed('collection', 'name', array(), array( + $form = $this->factory->createNamed('name', 'collection', array(), array( 'type' => 'text', )); @@ -333,7 +333,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testForm() { - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add('firstName', 'text') ->add('lastName', 'text') ->getForm(); @@ -361,9 +361,9 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest // https://github.com/symfony/symfony/issues/2308 public function testNestedFormError() { - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add($this->factory - ->createNamedBuilder('form', 'child', null, array('error_bubbling' => false)) + ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) ->add('grandChild', 'form') ) ->getForm(); @@ -386,11 +386,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest ->method('generateCsrfToken') ->will($this->returnValue('foo&bar')); - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add($this->factory // No CSRF protection on nested forms - ->createNamedBuilder('form', 'child') - ->add($this->factory->createNamedBuilder('text', 'grandchild')) + ->createNamedBuilder('child', 'form') + ->add($this->factory->createNamedBuilder('grandchild', 'text')) ) ->getForm(); @@ -407,7 +407,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRepeated() { - $form = $this->factory->createNamed('repeated', 'name', 'foobar', array( + $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( 'type' => 'text', )); @@ -433,7 +433,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testRepeatedWithCustomOptions() { - $form = $this->factory->createNamed('repeated', 'name', null, array( + $form = $this->factory->createNamed('name', 'repeated', null, array( // the global required value cannot be overriden 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2') @@ -461,7 +461,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testSearchInputName() { - $form = $this->factory->createNamedBuilder('form', 'full') + $form = $this->factory->createNamedBuilder('full', 'form') ->add('name', 'search') ->getForm(); @@ -482,7 +482,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testLabelHasNoId() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, @@ -501,7 +501,7 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest public function testThemeBlockInheritance($theme) { $view = $this->factory - ->createNamed('email', 'name') + ->createNamed('name', 'email') ->createView() ; @@ -518,11 +518,11 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest */ public function testThemeInheritance($parentTheme, $childTheme) { - $child = $this->factory->createNamedBuilder('form', 'child') + $child = $this->factory->createNamedBuilder('child', 'form') ->add('field', 'text') ->getForm(); - $view = $this->factory->createNamedBuilder('form', 'parent') + $view = $this->factory->createNamedBuilder('parent', 'form') ->add('field', 'text') ->getForm() ->add($child) diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index b986975e6e..0217442bff 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -114,7 +114,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testEnctype() { - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add('file', 'file') ->getForm(); @@ -123,7 +123,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testNoEnctype() { - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add('text', 'text') ->getForm(); @@ -132,7 +132,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabel() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $view = $form->createView(); $this->renderWidget($view, array('label' => 'foo')); $html = $this->renderLabel($view); @@ -147,7 +147,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelOnForm() { - $form = $this->factory->createNamed('date', 'name'); + $form = $this->factory->createNamed('name', 'date'); $view = $form->createView(); $this->renderWidget($view, array('label' => 'foo')); $html = $this->renderLabel($view); @@ -162,7 +162,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelWithCustomTextPassedAsOption() { - $form = $this->factory->createNamed('text', 'name', null, array( + $form = $this->factory->createNamed('name', 'text', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView()); @@ -177,7 +177,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelWithCustomTextPassedDirectly() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), 'Custom label'); $this->assertMatchesXpath($html, @@ -190,7 +190,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelWithCustomTextPassedAsOptionAndDirectly() { - $form = $this->factory->createNamed('text', 'name', null, array( + $form = $this->factory->createNamed('name', 'text', null, array( 'label' => 'Custom label', )); $html = $this->renderLabel($form->createView(), 'Overridden label'); @@ -205,7 +205,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelDoesNotRenderFieldAttributes() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), null, array( 'attr' => array( 'class' => 'my&class' @@ -222,7 +222,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelWithCustomOptionsPassedDirectly() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), null, array( 'label_attr' => array( 'class' => 'my&class' @@ -239,7 +239,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLabelWithCustomTextAndCustomOptionsPassedDirectly() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), 'Custom label', array( 'label_attr' => array( 'class' => 'my&class' @@ -257,7 +257,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testErrors() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $form->addError(new FormError('Error 1')); $form->addError(new FormError('Error 2')); $view = $form->createView(); @@ -276,7 +276,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testWidgetById() { - $form = $this->factory->createNamed('text', 'text_id'); + $form = $this->factory->createNamed('text_id', 'text'); $html = $this->renderWidget($form->createView()); $this->assertMatchesXpath($html, @@ -293,7 +293,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCheckedCheckbox() { - $form = $this->factory->createNamed('checkbox', 'name', true); + $form = $this->factory->createNamed('name', 'checkbox', true); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -307,7 +307,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testUncheckedCheckbox() { - $form = $this->factory->createNamed('checkbox', 'name', false); + $form = $this->factory->createNamed('name', 'checkbox', false); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -320,7 +320,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCheckboxWithValue() { - $form = $this->factory->createNamed('checkbox', 'name', false, array( + $form = $this->factory->createNamed('name', 'checkbox', false, array( 'value' => 'foo&bar', )); @@ -335,7 +335,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoice() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -356,7 +356,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceWithPreferred() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -380,7 +380,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceWithPreferredAndNoSeparator() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -402,7 +402,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceWithPreferredAndBlankSeparator() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&b'), 'multiple' => false, @@ -425,7 +425,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testChoiceWithOnlyPreferred() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'preferred_choices' => array('&a', '&b'), 'multiple' => false, @@ -441,7 +441,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceNonRequired() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -464,7 +464,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceNonRequiredNoneSelected() { - $form = $this->factory->createNamed('choice', 'name', null, array( + $form = $this->factory->createNamed('name', 'choice', null, array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => false, @@ -487,7 +487,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceWithNonRequiredEmptyValue() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => false, @@ -511,7 +511,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceRequiredWithEmptyValue() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -535,7 +535,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceRequiredWithEmptyValueViaView() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => true, 'multiple' => false, @@ -558,7 +558,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceGrouped() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array( 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'Group&2' => array('&c' => 'Choice&C'), @@ -588,7 +588,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testMultipleChoice() { - $form = $this->factory->createNamed('choice', 'name', array('&a'), array( + $form = $this->factory->createNamed('name', 'choice', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => true, 'expanded' => false, @@ -609,7 +609,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testMultipleChoiceSkipEmptyValue() { - $form = $this->factory->createNamed('choice', 'name', array('&a'), array( + $form = $this->factory->createNamed('name', 'choice', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => true, 'expanded' => false, @@ -631,7 +631,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testMultipleChoiceNonRequired() { - $form = $this->factory->createNamed('choice', 'name', array('&a'), array( + $form = $this->factory->createNamed('name', 'choice', array('&a'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'required' => false, 'multiple' => true, @@ -653,7 +653,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceExpanded() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -675,7 +675,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceExpandedSkipEmptyValue() { - $form = $this->factory->createNamed('choice', 'name', '&a', array( + $form = $this->factory->createNamed('name', 'choice', '&a', array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -698,7 +698,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSingleChoiceExpandedWithBooleanValue() { - $form = $this->factory->createNamed('choice', 'name', true, array( + $form = $this->factory->createNamed('name', 'choice', true, array( 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), 'multiple' => false, 'expanded' => true, @@ -720,7 +720,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testMultipleChoiceExpanded() { - $form = $this->factory->createNamed('choice', 'name', array('&a', '&c'), array( + $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), 'multiple' => true, 'expanded' => true, @@ -745,7 +745,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCountry() { - $form = $this->factory->createNamed('country', 'name', 'AT'); + $form = $this->factory->createNamed('name', 'country', 'AT'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -758,7 +758,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCountryWithEmptyValue() { - $form = $this->factory->createNamed('country', 'name', 'AT', array( + $form = $this->factory->createNamed('name', 'country', 'AT', array( 'empty_value' => 'Select&Country', 'required' => false, )); @@ -775,7 +775,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTime() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -814,7 +814,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeWithEmptyValueGlobal() { - $form = $this->factory->createNamed('datetime', 'name', null, array( + $form = $this->factory->createNamed('name', 'datetime', null, array( 'input' => 'string', 'empty_value' => 'Change&Me', 'required' => false, @@ -854,7 +854,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeWithEmptyValueOnTime() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03', array( 'input' => 'string', 'empty_value' => array('hour' => 'Change&Me', 'minute' => 'Change&Me'), 'required' => false, @@ -894,7 +894,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeWithSeconds() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -936,7 +936,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeSingleText() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'single_text', 'time_widget' => 'single_text', @@ -962,7 +962,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeWithWidgetSingleText() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -978,7 +978,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { - $form = $this->factory->createNamed('datetime', 'name', '2011-02-03 04:05:06', array( + $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( 'input' => 'string', 'date_widget' => 'choice', 'time_widget' => 'choice', @@ -996,7 +996,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateChoice() { - $form = $this->factory->createNamed('date', 'name', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( 'input' => 'string', 'widget' => 'choice', )); @@ -1021,7 +1021,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateChoiceWithEmptyValueGlobal() { - $form = $this->factory->createNamed('date', 'name', null, array( + $form = $this->factory->createNamed('name', 'date', null, array( 'input' => 'string', 'widget' => 'choice', 'empty_value' => 'Change&Me', @@ -1048,7 +1048,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateChoiceWithEmptyValueOnYear() { - $form = $this->factory->createNamed('date', 'name', null, array( + $form = $this->factory->createNamed('name', 'date', null, array( 'input' => 'string', 'widget' => 'choice', 'required' => false, @@ -1075,7 +1075,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateText() { - $form = $this->factory->createNamed('date', 'name', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( 'input' => 'string', 'widget' => 'text', )); @@ -1103,7 +1103,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDateSingleText() { - $form = $this->factory->createNamed('date', 'name', '2011-02-03', array( + $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1130,7 +1130,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testBirthDay() { - $form = $this->factory->createNamed('birthday', 'name', '2000-02-03', array( + $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( 'input' => 'string', )); @@ -1154,7 +1154,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testBirthDayWithEmptyValue() { - $form = $this->factory->createNamed('birthday', 'name', '1950-01-01', array( + $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( 'input' => 'string', 'empty_value' => '', 'required' => false, @@ -1183,7 +1183,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testEmail() { - $form = $this->factory->createNamed('email', 'name', 'foo&bar'); + $form = $this->factory->createNamed('name', 'email', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1197,7 +1197,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testEmailWithMaxLength() { - $form = $this->factory->createNamed('email', 'name', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( 'max_length' => 123, )); @@ -1213,7 +1213,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testFile() { - $form = $this->factory->createNamed('file', 'name'); + $form = $this->factory->createNamed('name', 'file'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1224,7 +1224,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testHidden() { - $form = $this->factory->createNamed('hidden', 'name', 'foo&bar'); + $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1237,7 +1237,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testReadOnly() { - $form = $this->factory->createNamed('text', 'name', null, array( + $form = $this->factory->createNamed('name', 'text', null, array( 'read_only' => true, )); @@ -1252,7 +1252,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testDisabled() { - $form = $this->factory->createNamed('text', 'name', null, array( + $form = $this->factory->createNamed('name', 'text', null, array( 'disabled' => true, )); @@ -1267,7 +1267,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testInteger() { - $form = $this->factory->createNamed('integer', 'name', 123); + $form = $this->factory->createNamed('name', 'integer', 123); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1280,7 +1280,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLanguage() { - $form = $this->factory->createNamed('language', 'name', 'de'); + $form = $this->factory->createNamed('name', 'language', 'de'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1293,7 +1293,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testLocale() { - $form = $this->factory->createNamed('locale', 'name', 'de_AT'); + $form = $this->factory->createNamed('name', 'locale', 'de_AT'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1306,7 +1306,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testMoney() { - $form = $this->factory->createNamed('money', 'name', 1234.56, array( + $form = $this->factory->createNamed('name', 'money', 1234.56, array( 'currency' => 'EUR', )); @@ -1322,7 +1322,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testNumber() { - $form = $this->factory->createNamed('number', 'name', 1234.56); + $form = $this->factory->createNamed('name', 'number', 1234.56); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1335,7 +1335,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testPassword() { - $form = $this->factory->createNamed('password', 'name', 'foo&bar'); + $form = $this->factory->createNamed('name', 'password', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1347,7 +1347,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testPasswordBoundNotAlwaysEmpty() { - $form = $this->factory->createNamed('password', 'name', null, array( + $form = $this->factory->createNamed('name', 'password', null, array( 'always_empty' => false, )); $form->bind('foo&bar'); @@ -1363,7 +1363,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testPasswordWithMaxLength() { - $form = $this->factory->createNamed('password', 'name', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( 'max_length' => 123, )); @@ -1378,7 +1378,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testPercent() { - $form = $this->factory->createNamed('percent', 'name', 0.1); + $form = $this->factory->createNamed('name', 'percent', 0.1); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1392,7 +1392,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCheckedRadio() { - $form = $this->factory->createNamed('radio', 'name', true); + $form = $this->factory->createNamed('name', 'radio', true); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1406,7 +1406,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testUncheckedRadio() { - $form = $this->factory->createNamed('radio', 'name', false); + $form = $this->factory->createNamed('name', 'radio', false); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1419,7 +1419,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testRadioWithValue() { - $form = $this->factory->createNamed('radio', 'name', false, array( + $form = $this->factory->createNamed('name', 'radio', false, array( 'value' => 'foo&bar', )); @@ -1434,7 +1434,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTextarea() { - $form = $this->factory->createNamed('textarea', 'name', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( 'pattern' => 'foo', )); @@ -1449,7 +1449,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testText() { - $form = $this->factory->createNamed('text', 'name', 'foo&bar'); + $form = $this->factory->createNamed('name', 'text', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1463,7 +1463,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTextWithMaxLength() { - $form = $this->factory->createNamed('text', 'name', 'foo&bar', array( + $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( 'max_length' => 123, )); @@ -1479,7 +1479,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testSearch() { - $form = $this->factory->createNamed('search', 'name', 'foo&bar'); + $form = $this->factory->createNamed('name', 'search', 'foo&bar'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1493,7 +1493,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTime() { - $form = $this->factory->createNamed('time', 'name', '04:05:06', array( + $form = $this->factory->createNamed('name', 'time', '04:05:06', array( 'input' => 'string', 'with_seconds' => false, )); @@ -1517,7 +1517,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimeWithSeconds() { - $form = $this->factory->createNamed('time', 'name', '04:05:06', array( + $form = $this->factory->createNamed('name', 'time', '04:05:06', array( 'input' => 'string', 'with_seconds' => true, )); @@ -1548,7 +1548,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimeText() { - $form = $this->factory->createNamed('time', 'name', '04:05:06', array( + $form = $this->factory->createNamed('name', 'time', '04:05:06', array( 'input' => 'string', 'widget' => 'text', )); @@ -1578,7 +1578,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimeSingleText() { - $form = $this->factory->createNamed('time', 'name', '04:05:06', array( + $form = $this->factory->createNamed('name', 'time', '04:05:06', array( 'input' => 'string', 'widget' => 'single_text', )); @@ -1594,7 +1594,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimeWithEmptyValueGlobal() { - $form = $this->factory->createNamed('time', 'name', null, array( + $form = $this->factory->createNamed('name', 'time', null, array( 'input' => 'string', 'empty_value' => 'Change&Me', 'required' => false, @@ -1619,7 +1619,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimeWithEmptyValueOnYear() { - $form = $this->factory->createNamed('time', 'name', null, array( + $form = $this->factory->createNamed('name', 'time', null, array( 'input' => 'string', 'required' => false, 'empty_value' => array('hour' => 'Change&Me'), @@ -1655,7 +1655,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimezone() { - $form = $this->factory->createNamed('timezone', 'name', 'Europe/Vienna'); + $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); $this->assertWidgetMatchesXpath($form->createView(), array(), '/select @@ -1673,7 +1673,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testTimezoneWithEmptyValue() { - $form = $this->factory->createNamed('timezone', 'name', null, array( + $form = $this->factory->createNamed('name', 'timezone', null, array( 'empty_value' => 'Select&Timezone', 'required' => false, )); @@ -1690,7 +1690,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testUrl() { $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; - $form = $this->factory->createNamed('url', 'name', $url); + $form = $this->factory->createNamed('name', 'url', $url); $this->assertWidgetMatchesXpath($form->createView(), array(), '/input @@ -1703,7 +1703,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testCollectionPrototype() { - $form = $this->factory->createNamedBuilder('form', 'name', array('items' => array('one', 'two', 'three'))) + $form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three'))) ->add('items', 'collection', array('allow_add' => true)) ->getForm() ->createView(); @@ -1721,7 +1721,7 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase public function testEmptyRootFormName() { - $form = $this->factory->createNamedBuilder('form', '', '') + $form = $this->factory->createNamedBuilder('', 'form', '') ->add('child', 'text') ->getForm(); diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index 9bf77d9c59..62ac603bb9 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -17,7 +17,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest { public function testRow() { - $form = $this->factory->createNamed('text', 'name'); + $form = $this->factory->createNamed('name', 'text'); $form->addError(new FormError('Error!')); $view = $form->createView(); $html = $this->renderRow($view); @@ -41,7 +41,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testRepeatedRow() { - $form = $this->factory->createNamed('repeated', 'name'); + $form = $this->factory->createNamed('name', 'repeated'); $html = $this->renderRow($form->createView()); $this->assertMatchesXpath($html, @@ -71,7 +71,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testRepeatedRowWithErrors() { - $form = $this->factory->createNamed('repeated', 'name'); + $form = $this->factory->createNamed('name', 'repeated'); $form->addError(new FormError('Error!')); $view = $form->createView(); $html = $this->renderRow($view); @@ -107,7 +107,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testRest() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('field1', 'text') ->add('field2', 'repeated') ->add('field3', 'text') @@ -154,7 +154,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testCollection() { - $form = $this->factory->createNamed('collection', 'name', array('a', 'b'), array( + $form = $this->factory->createNamed('name', 'collection', array('a', 'b'), array( 'type' => 'text', )); @@ -172,7 +172,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testEmptyCollection() { - $form = $this->factory->createNamed('collection', 'name', array(), array( + $form = $this->factory->createNamed('name', 'collection', array(), array( 'type' => 'text', )); @@ -186,7 +186,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testForm() { - $view = $this->factory->createNamedBuilder('form', 'name') + $view = $this->factory->createNamedBuilder('name', 'form') ->add('firstName', 'text') ->add('lastName', 'text') ->getForm() @@ -223,9 +223,9 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest // https://github.com/symfony/symfony/issues/2308 public function testNestedFormError() { - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add($this->factory - ->createNamedBuilder('form', 'child', null, array('error_bubbling' => false)) + ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) ->add('grandChild', 'form') ) ->getForm(); @@ -250,11 +250,11 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest ->method('generateCsrfToken') ->will($this->returnValue('foo&bar')); - $form = $this->factory->createNamedBuilder('form', 'name') + $form = $this->factory->createNamedBuilder('name', 'form') ->add($this->factory // No CSRF protection on nested forms - ->createNamedBuilder('form', 'child') - ->add($this->factory->createNamedBuilder('text', 'grandchild')) + ->createNamedBuilder('child', 'form') + ->add($this->factory->createNamedBuilder('grandchild', 'text')) ) ->getForm(); @@ -274,7 +274,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testRepeated() { - $form = $this->factory->createNamed('repeated', 'name', 'foobar', array( + $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( 'type' => 'text', )); @@ -308,7 +308,7 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest public function testRepeatedWithCustomOptions() { - $form = $this->factory->createNamed('repeated', 'name', 'foobar', array( + $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( 'type' => 'password', 'first_options' => array('label' => 'Test', 'required' => false), 'second_options' => array('label' => 'Test2') diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php index 0213f1af31..bc2c650995 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php @@ -61,11 +61,11 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase $this->factory->expects($this->at(0)) ->method('createNamed') - ->with('text', 1, null, array('property_path' => '[1]', 'max_length' => 10)) + ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10)) ->will($this->returnValue($this->getForm('1'))); $this->factory->expects($this->at(1)) ->method('createNamed') - ->with('text', 2, null, array('property_path' => '[2]', 'max_length' => 10)) + ->with(2, 'text', null, array('property_path' => '[2]', 'max_length' => 10)) ->will($this->returnValue($this->getForm('2'))); $data = array(1 => 'string', 2 => 'string'); @@ -105,7 +105,7 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase $this->factory->expects($this->once()) ->method('createNamed') - ->with('text', 1, null, array('property_path' => '[1]', 'max_length' => 10)) + ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10)) ->will($this->returnValue($this->getForm('1'))); $data = array(0 => 'string', 1 => 'string'); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 3c879fe4d8..2724f2986b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -693,7 +693,7 @@ class ChoiceTypeTest extends TypeTestCase public function testAdjustFullNameForMultipleNonExpanded() { - $form = $this->factory->createNamed('choice', 'name', null, array( + $form = $this->factory->createNamed('name', 'choice', null, array( 'multiple' => true, 'expanded' => false, 'choices' => $this->choices, @@ -706,7 +706,7 @@ class ChoiceTypeTest extends TypeTestCase // https://github.com/symfony/symfony/issues/3298 public function testInitializeWithEmptyChoices() { - $this->factory->createNamed('choice', 'name', null, array( + $this->factory->createNamed('name', 'choice', null, array( 'choices' => array(), )); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 19fc86f534..c39788e4a9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -102,7 +102,7 @@ class FormTypeTest extends TypeTestCase public function testPassIdAndNameToView() { - $form = $this->factory->createNamed('form', 'name'); + $form = $this->factory->createNamed('name', 'form'); $view = $form->createView(); $this->assertEquals('name', $view->get('id')); @@ -112,7 +112,7 @@ class FormTypeTest extends TypeTestCase public function testStripLeadingUnderscoresAndDigitsFromId() { - $form = $this->factory->createNamed('form', '_09name'); + $form = $this->factory->createNamed('_09name', 'form'); $view = $form->createView(); $this->assertEquals('name', $view->get('id')); @@ -122,8 +122,8 @@ class FormTypeTest extends TypeTestCase public function testPassIdAndNameToViewWithParent() { - $parent = $this->factory->createNamed('form', 'parent'); - $parent->add($this->factory->createNamed('form', 'child')); + $parent = $this->factory->createNamed('parent', 'form'); + $parent->add($this->factory->createNamed('child', 'form')); $view = $parent->createView(); $this->assertEquals('parent_child', $view['child']->get('id')); @@ -133,9 +133,9 @@ class FormTypeTest extends TypeTestCase public function testPassIdAndNameToViewWithGrandParent() { - $parent = $this->factory->createNamed('form', 'parent'); - $parent->add($this->factory->createNamed('form', 'child')); - $parent['child']->add($this->factory->createNamed('form', 'grand_child')); + $parent = $this->factory->createNamed('parent', 'form'); + $parent->add($this->factory->createNamed('child', 'form')); + $parent['child']->add($this->factory->createNamed('grand_child', 'form')); $view = $parent->createView(); $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->get('id')); @@ -145,8 +145,8 @@ class FormTypeTest extends TypeTestCase public function testNonReadOnlyFormWithReadOnlyParentBeingReadOnly() { - $parent = $this->factory->createNamed('form', 'parent', null, array('read_only' => true)); - $child = $this->factory->createNamed('form', 'child'); + $parent = $this->factory->createNamed('parent', 'form', null, array('read_only' => true)); + $child = $this->factory->createNamed('child', 'form'); $view = $parent->add($child)->createView(); $this->assertTrue($view['child']->get('read_only')); @@ -154,8 +154,8 @@ class FormTypeTest extends TypeTestCase public function testReadOnlyFormWithNonReadOnlyParentBeingReadOnly() { - $parent = $this->factory->createNamed('form', 'parent'); - $child = $this->factory->createNamed('form', 'child', null, array('read_only' => true)); + $parent = $this->factory->createNamed('parent', 'form'); + $child = $this->factory->createNamed('child', 'form', null, array('read_only' => true)); $view = $parent->add($child)->createView(); $this->assertTrue($view['child']->get('read_only')); @@ -163,8 +163,8 @@ class FormTypeTest extends TypeTestCase public function testNonReadOnlyFormWithNonReadOnlyParentBeingNonReadOnly() { - $parent = $this->factory->createNamed('form', 'parent'); - $child = $this->factory->createNamed('form', 'child'); + $parent = $this->factory->createNamed('parent', 'form'); + $child = $this->factory->createNamed('child', 'form'); $view = $parent->add($child)->createView(); $this->assertFalse($view['child']->get('read_only')); @@ -188,7 +188,7 @@ class FormTypeTest extends TypeTestCase public function testPassDefaultLabelToView() { - $form = $this->factory->createNamed('form', '__test___field'); + $form = $this->factory->createNamed('__test___field', 'form'); $view = $form->createView(); $this->assertSame('Test field', $view->get('label')); @@ -196,7 +196,7 @@ class FormTypeTest extends TypeTestCase public function testPassLabelToView() { - $form = $this->factory->createNamed('form', '__test___field', null, array('label' => 'My label')); + $form = $this->factory->createNamed('__test___field', 'form', null, array('label' => 'My label')); $view = $form->createView(); $this->assertSame('My label', $view->get('label')); @@ -216,8 +216,8 @@ class FormTypeTest extends TypeTestCase 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => false, )); - $form->add($this->factory->createNamed('form', 'firstName')); - $form->add($this->factory->createNamed('form', 'lastName')); + $form->add($this->factory->createNamed('firstName', 'form')); + $form->add($this->factory->createNamed('lastName', 'form')); $form->setData(null); // partially empty, still an object is created @@ -237,8 +237,8 @@ class FormTypeTest extends TypeTestCase 'data' => new Author(), 'required' => false, )); - $form->add($this->factory->createNamed('form', 'firstName')); - $form->add($this->factory->createNamed('form', 'lastName')); + $form->add($this->factory->createNamed('firstName', 'form')); + $form->add($this->factory->createNamed('lastName', 'form')); $form->setData(null); // partially empty, still an object is created @@ -257,7 +257,7 @@ class FormTypeTest extends TypeTestCase 'data_class' => null, 'required' => false, )); - $form->add($this->factory->createNamed('form', 'firstName')); + $form->add($this->factory->createNamed('firstName', 'form')); $form->setData(null); $form->bind(array('firstName' => 'Bernhard')); @@ -271,8 +271,8 @@ class FormTypeTest extends TypeTestCase 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => false, )); - $form->add($this->factory->createNamed('form', 'firstName')); - $form->add($this->factory->createNamed('form', 'lastName')); + $form->add($this->factory->createNamed('firstName', 'form')); + $form->add($this->factory->createNamed('lastName', 'form')); $form->setData(null); $form->bind(array('firstName' => '', 'lastName' => '')); @@ -286,8 +286,8 @@ class FormTypeTest extends TypeTestCase 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'required' => true, )); - $form->add($this->factory->createNamed('form', 'firstName')); - $form->add($this->factory->createNamed('form', 'lastName')); + $form->add($this->factory->createNamed('firstName', 'form')); + $form->add($this->factory->createNamed('lastName', 'form')); $form->setData(null); $form->bind(array('firstName' => '', 'lastName' => '')); @@ -301,7 +301,7 @@ class FormTypeTest extends TypeTestCase public function testBindWithEmptyDataStoresArrayIfNoClassAvailable() { $form = $this->factory->create('form'); - $form->add($this->factory->createNamed('form', 'firstName')); + $form->add($this->factory->createNamed('firstName', 'form')); $form->setData(null); $form->bind(array('firstName' => 'Bernhard')); @@ -333,7 +333,7 @@ class FormTypeTest extends TypeTestCase 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', 'empty_data' => $author, )); - $form->add($this->factory->createNamed('form', 'firstName')); + $form->add($this->factory->createNamed('firstName', 'form')); $form->bind(array('firstName' => 'Bernhard')); @@ -381,7 +381,7 @@ class FormTypeTest extends TypeTestCase public function testNameCanBeEmptyString() { - $form = $this->factory->createNamed('form', ''); + $form = $this->factory->createNamed('', 'form'); $this->assertEquals('', $form->getName()); } @@ -569,7 +569,7 @@ class FormTypeTest extends TypeTestCase public function testPropertyPathNullImpliesDefault() { - $form = $this->factory->createNamed('form', 'name', null, array( + $form = $this->factory->createNamed('name', 'form', null, array( 'property_path' => null, )); @@ -580,7 +580,7 @@ class FormTypeTest extends TypeTestCase // BC public function testPropertyPathFalseImpliesDefaultNotMapped() { - $form = $this->factory->createNamed('form', 'name', null, array( + $form = $this->factory->createNamed('name', 'form', null, array( 'property_path' => false, )); diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php index aae90101f1..dcd641f879 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php @@ -71,7 +71,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase public function testNoCsrfProtectionByDefaultIfNotSingleControlButNotRoot() { $view = $this->factory - ->createNamedBuilder('form', 'root') + ->createNamedBuilder('root', 'form') ->add($this->factory ->createNamedBuilder('form', 'form', null, array( 'csrf_field_name' => 'csrf', @@ -198,7 +198,7 @@ class FormTypeCsrfExtensionTest extends TypeTestCase ->method('isCsrfTokenValid'); $form = $this->factory - ->createNamedBuilder('form', 'root') + ->createNamedBuilder('root', 'form') ->add($this->factory ->createNamedBuilder('form', 'form', null, array( 'csrf_field_name' => 'csrf', diff --git a/src/Symfony/Component/Form/Tests/FormBuilderTest.php b/src/Symfony/Component/Form/Tests/FormBuilderTest.php index 68db15fd40..89ca355e08 100644 --- a/src/Symfony/Component/Form/Tests/FormBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormBuilderTest.php @@ -82,7 +82,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'foo') + ->with('foo', 'text') ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); $this->assertCount(0, $this->builder->all()); @@ -120,7 +120,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'foo', null, array()) + ->with('foo', 'text', null, array()) ; $builder = $this->builder->create('foo'); @@ -140,7 +140,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with($expectedType, $expectedName, null, $expectedOptions) + ->with($expectedName, $expectedType, null, $expectedOptions) ->will($this->returnValue($this->getFormBuilder())); $this->builder->add($expectedName, $expectedType, $expectedOptions); @@ -192,7 +192,7 @@ class FormBuilderTest extends \PHPUnit_Framework_TestCase $this->factory ->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'bar', null, array(), $this->builder) + ->with('bar', 'text', null, array(), $this->builder) ; $this->factory diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index ea88a5bcdc..b3dd506495 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -118,7 +118,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->extension1->addType($type); - $builder = $this->factory->createNamedBuilder('foo', 'bar'); + $builder = $this->factory->createNamedBuilder('bar', 'foo'); $this->assertTrue($builder instanceof FormBuilder); $this->assertEquals('bar', $builder->getName()); @@ -135,7 +135,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension2->addTypeExtension($ext2); $this->extension2->addType($type); - $builder = $this->factory->createNamedBuilder('foo', 'bar'); + $builder = $this->factory->createNamedBuilder('bar', 'foo'); $this->assertTrue($builder->hasAttribute('foo')); $this->assertTrue($builder->hasAttribute('bar')); @@ -147,7 +147,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->extension1->addType($type); - $builder = $this->factory->createNamedBuilder('foo', 'bar', 'xyz'); + $builder = $this->factory->createNamedBuilder('bar', 'foo', 'xyz'); // see FooType::buildForm() $this->assertEquals('xyz', $builder->getAttribute('data_option')); @@ -158,7 +158,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->extension1->addType($type); - $builder = $this->factory->createNamedBuilder('foo', 'bar', 'xyz', array( + $builder = $this->factory->createNamedBuilder('bar', 'foo', 'xyz', array( 'data' => 'abc', )); @@ -181,7 +181,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar'); + $this->factory->createNamedBuilder('bar', 'foo'); } /** @@ -199,7 +199,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar'); + $this->factory->createNamedBuilder('bar', 'foo'); } /** @@ -217,7 +217,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar'); + $this->factory->createNamedBuilder('bar', 'foo'); } /** @@ -238,7 +238,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar'); + $this->factory->createNamedBuilder('bar', 'foo'); } /** @@ -249,7 +249,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar', null, array( + $this->factory->createNamedBuilder('bar', 'foo', null, array( 'invalid' => 'xyz', )); } @@ -262,7 +262,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->extension1->addType($type); - $this->factory->createNamedBuilder('foo', 'bar', null, array( + $this->factory->createNamedBuilder('bar', 'foo', null, array( 'a_or_b' => 'c', )); } @@ -274,7 +274,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $this->extension1->addTypeExtension(new FooTypeBarExtension()); // no exception this time - $this->factory->createNamedBuilder('foo', 'bar', null, array( + $this->factory->createNamedBuilder('bar', 'foo', null, array( 'a_or_b' => 'c', )); } @@ -284,7 +284,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $type = new FooType(); $this->assertFalse($this->factory->hasType('foo')); - $builder = $this->factory->createNamedBuilder($type, 'bar'); + $builder = $this->factory->createNamedBuilder('bar', $type); $this->assertTrue($builder instanceof FormBuilder); $this->assertTrue($this->factory->hasType('foo')); @@ -296,7 +296,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase */ public function testCreateNamedBuilderThrowsUnderstandableException() { - $this->factory->createNamedBuilder(new \StdClass, 'name'); + $this->factory->createNamedBuilder('name', new \stdClass()); } public function testCreateUsesTypeNameAsName() @@ -333,7 +333,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('password', 'firstName', null, array('max_length' => 7)) + ->with('firstName', 'password', null, array('max_length' => 7)) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -352,7 +352,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName') + ->with('firstName', 'text') ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); @@ -375,7 +375,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('max_length' => 11)) + ->with('firstName', 'text', null, array('max_length' => 11)) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -410,7 +410,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('max_length' => 20)) + ->with('firstName', 'text', null, array('max_length' => 20)) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -443,7 +443,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('pattern' => '.{5,}')) + ->with('firstName', 'text', null, array('pattern' => '.{5,}')) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -478,7 +478,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('pattern' => '.{5,10}')) + ->with('firstName', 'text', null, array('pattern' => '.{5,10}')) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -511,7 +511,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('required' => false)) + ->with('firstName', 'text', null, array('required' => false)) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -544,7 +544,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase $factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'firstName', null, array('pattern' => '/[a-zA-Z]/')) + ->with('firstName', 'text', null, array('pattern' => '/[a-zA-Z]/')) ->will($this->returnValue('builderInstance')); $builder = $factory->createBuilderForProperty( @@ -565,7 +565,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase ->getMock() ; - $builder = $this->factory->createNamedBuilder('foo', 'bar', null, array(), $parentBuilder); + $builder = $this->factory->createNamedBuilder('bar', 'foo', null, array(), $parentBuilder); $this->assertNotEquals($builder, $builder->getParent()); $this->assertEquals($parentBuilder, $builder->getParent()); @@ -575,7 +575,7 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase { $factory = new FormFactory(array(new \Symfony\Component\Form\Extension\Core\CoreExtension())); - $form = $factory->createNamedBuilder(new AuthorType(), 'author')->getForm(); + $form = $factory->createNamedBuilder('author', new AuthorType())->getForm(); $form->bind(array('firstName' => 'John', 'lastName' => 'Smith')); $author = new Author(); diff --git a/src/Symfony/Component/Form/Tests/FormTest.php b/src/Symfony/Component/Form/Tests/FormTest.php index f0fb10e2b0..40f0bb8713 100644 --- a/src/Symfony/Component/Form/Tests/FormTest.php +++ b/src/Symfony/Component/Form/Tests/FormTest.php @@ -296,7 +296,7 @@ class FormTest extends \PHPUnit_Framework_TestCase { $this->factory->expects($this->once()) ->method('createNamedBuilder') - ->with('text', 'name', null, array()) + ->with('name', 'text', null, array()) ->will($this->returnValue($this->getBuilder('name'))); $form = $this->getBuilder('person')