From f91660db9c7431c1e87cf9967a0496436ce5f6bd Mon Sep 17 00:00:00 2001 From: umpirsky Date: Fri, 30 Mar 2012 15:35:41 +0200 Subject: [PATCH 1/7] Added test for prototype label. --- .../Tests/Extension/Core/Type/CollectionTypeTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index b8f4b19858..0ce7aad2e4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -185,4 +185,15 @@ class CollectionTypeTest extends TypeTestCase $this->assertSame('__test__', $form->getAttribute('prototype')->getName()); } + + public function testPrototypeDefaultLabel() + { + $form = $this->factory->create('collection', array(), array( + 'type' => 'file', + 'allow_add' => true, + 'prototype' => true, + )); + + $this->assertSame('__name__', $form->createView()->get('prototype')->get('label')); + } } From a430f3d8a6caffde3a6439cf0c5778abb1508413 Mon Sep 17 00:00:00 2001 From: "Thomas Chmielowiec (chmielot)" Date: Wed, 4 Apr 2012 15:35:00 +0200 Subject: [PATCH 2/7] [#3446] [Form] Fix getChoicesForValues of EntityChoiceList on empty values --- .../Form/ChoiceList/EntityChoiceList.php | 3 +++ .../Form/ChoiceList/EntityChoiceListTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index 6ad960bff1..2debb97e25 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -175,6 +175,9 @@ class EntityChoiceList extends ObjectChoiceList // Optimize performance in case we have an entity loader and // a single-field identifier if (count($this->identifier) === 1 && $this->entityLoader) { + if (empty($values)) { + return array(); + } return $this->entityLoader->getEntitiesByIds(current($this->identifier), $values); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php index e0bc7f6763..97867e7591 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/EntityChoiceListTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; +use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Bridge\Doctrine\Tests\DoctrineOrmTestCase; use Symfony\Bridge\Doctrine\Tests\Fixtures\ItemGroupEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity; @@ -250,4 +251,19 @@ class EntityChoiceListTest extends DoctrineOrmTestCase $this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2))); $this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2))); } + + // Ticket #3446 + public function testGetEmptyArrayChoicesForEmptyValues() + { + $qb = $this->em->createQueryBuilder()->select('s')->from(self::SINGLE_IDENT_CLASS, 's'); + $entityLoader = new ORMQueryBuilderLoader($qb); + $choiceList = new EntityChoiceList( + $this->em, + self::SINGLE_IDENT_CLASS, + null, + $entityLoader + ); + + $this->assertEquals(array(), $choiceList->getChoicesForValues(array())); + } } From 6e0b03a6e21cbb556524eaf9be1436bbcd244b51 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 6 Apr 2012 19:45:42 +0200 Subject: [PATCH 3/7] [Form] Fixed label of prototype in CollectionType --- .../Component/Form/Extension/Core/Type/CollectionType.php | 4 +++- .../Form/Tests/Extension/Core/Type/CollectionTypeTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index c094c2126c..ec20ec617d 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -26,7 +26,9 @@ class CollectionType extends AbstractType public function buildForm(FormBuilder $builder, array $options) { if ($options['allow_add'] && $options['prototype']) { - $prototype = $builder->create($options['prototype_name'], $options['type'], $options['options']); + $prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array( + 'label' => $options['prototype_name'] . 'label__', + ), $options['options'])); $builder->setAttribute('prototype', $prototype->getForm()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index 0ce7aad2e4..b0bb62508f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -192,8 +192,9 @@ class CollectionTypeTest extends TypeTestCase 'type' => 'file', 'allow_add' => true, 'prototype' => true, + 'prototype_name' => '__test__', )); - $this->assertSame('__name__', $form->createView()->get('prototype')->get('label')); + $this->assertSame('__test__label__', $form->createView()->get('prototype')->get('label')); } } From 658472193dc153a5e90ff3778311aaf887c72081 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 6 Apr 2012 19:50:06 +0200 Subject: [PATCH 4/7] [Form] Improved labels generated by default from form names --- .../Form/Extension/Core/Type/FieldType.php | 2 +- .../Tests/Extension/Core/Type/FieldTypeTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php b/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php index b51323bb09..d9bbe6222c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FieldType.php @@ -200,6 +200,6 @@ class FieldType extends AbstractType private function humanize($text) { - return ucfirst(strtolower(str_replace('_', ' ', $text))); + return ucfirst(trim(strtolower(preg_replace('/[_\s]+/', ' ', $text)))); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FieldTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FieldTypeTest.php index 7b0aee4d3f..d1a547c8b7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FieldTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FieldTypeTest.php @@ -188,6 +188,22 @@ class FieldTypeTest extends TypeTestCase $this->assertSame('test', $view->get('translation_domain')); } + public function testPassDefaultLabelToView() + { + $form = $this->factory->createNamed('field', '__test___field'); + $view = $form->createView(); + + $this->assertSame('Test field', $view->get('label')); + } + + public function testPassLabelToView() + { + $form = $this->factory->createNamed('field', '__test___field', null, array('label' => 'My label')); + $view = $form->createView(); + + $this->assertSame('My label', $view->get('label')); + } + public function testDefaultTranslationDomain() { $form = $this->factory->create('field'); From 1c3e4ac694150450094ef03c1700c905ad35f4c0 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Fri, 6 Apr 2012 14:29:48 -0400 Subject: [PATCH 5/7] [DependencyInjection] Fix Yaml file loader test This broke when 2.0 was recently merged into master with b9daae28476385d16984a729b9e7c8e30911fa23, as the Yaml fixture change from 24a0d0a2dcf334efc7d85f1c816c01d7fa4111f8 was not included. --- .../DependencyInjection/Tests/Fixtures/yaml/services6.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index 429aa9f679..eaa52bda62 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -14,6 +14,7 @@ services: class: FooClass calls: - [ setBar, [] ] + - [ setBar ] method_call2: class: FooClass calls: From 46c7ae1ed4c3522deddce35c7f42e50bb73af509 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Date: Fri, 6 Apr 2012 22:15:14 -0300 Subject: [PATCH 6/7] added composer.lock to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 422f1ce840..83ef63d16b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ phpunit.xml +composer.lock autoload.php /vendor/ From f3efea3a6ef399a9cdef03c280874d9c52974a71 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Date: Fri, 6 Apr 2012 23:24:52 -0300 Subject: [PATCH 7/7] [Propel1Bridge][TwigBridge] fixed export instructions in the README files --- src/Symfony/Bridge/Propel1/README.md | 6 +++--- src/Symfony/Bridge/Twig/README.md | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/README.md b/src/Symfony/Bridge/Propel1/README.md index d281c2a21d..f3ca773557 100644 --- a/src/Symfony/Bridge/Propel1/README.md +++ b/src/Symfony/Bridge/Propel1/README.md @@ -15,6 +15,6 @@ Components, declare the following environment variables before running PHPUnit: export PROPEL1=../path/to/Propel - export HTTP_FOUNDATION=../path/to/HttpFoundation - export HTTP_KERNEL=../path/to/HttpKernel - export HTTP_FORM=../path/to/Form + export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation + export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel + export SYMFONY_FORM=../path/to/Form diff --git a/src/Symfony/Bridge/Twig/README.md b/src/Symfony/Bridge/Twig/README.md index 0fac6c5bcd..a2ed06829a 100644 --- a/src/Symfony/Bridge/Twig/README.md +++ b/src/Symfony/Bridge/Twig/README.md @@ -15,8 +15,8 @@ If you also want to run the unit tests that depend on other Symfony Components, declare the following environment variables before running PHPUnit: - export HTTP_TWIG=../path/to/Twig - export HTTP_FORM=../path/to/Form - export HTTP_TRANSLATION=../path/to/Translation - export HTTP_EVENT_DISPATCHER=../path/to/EventDispatcher - export HTTP_LOCALE=../path/to/Locale + export TWIG=../path/to/Twig + export SYMFONY_FORM=../path/to/Form + export SYMFONY_TRANSLATION=../path/to/Translation + export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher + export SYMFONY_LOCALE=../path/to/Locale