Merge branch 'master' into cs-fixes
This commit is contained in:
commit
abd59c3dbd
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
composer.lock
|
||||||
autoload.php
|
autoload.php
|
||||||
/vendor/
|
/vendor/
|
||||||
|
@ -175,6 +175,9 @@ class EntityChoiceList extends ObjectChoiceList
|
|||||||
// Optimize performance in case we have an entity loader and
|
// Optimize performance in case we have an entity loader and
|
||||||
// a single-field identifier
|
// a single-field identifier
|
||||||
if (count($this->identifier) === 1 && $this->entityLoader) {
|
if (count($this->identifier) === 1 && $this->entityLoader) {
|
||||||
|
if (empty($values)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
return $this->entityLoader->getEntitiesByIds(current($this->identifier), $values);
|
return $this->entityLoader->getEntitiesByIds(current($this->identifier), $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
|
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\DoctrineOrmTestCase;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\ItemGroupEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\ItemGroupEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIdentEntity;
|
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->getValuesForChoices(array($item1, $item2)));
|
||||||
$this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,6 @@ Components, declare the following environment variables before running
|
|||||||
PHPUnit:
|
PHPUnit:
|
||||||
|
|
||||||
export PROPEL1=../path/to/Propel
|
export PROPEL1=../path/to/Propel
|
||||||
export HTTP_FOUNDATION=../path/to/HttpFoundation
|
export SYMFONY_HTTP_FOUNDATION=../path/to/HttpFoundation
|
||||||
export HTTP_KERNEL=../path/to/HttpKernel
|
export SYMFONY_HTTP_KERNEL=../path/to/HttpKernel
|
||||||
export HTTP_FORM=../path/to/Form
|
export SYMFONY_FORM=../path/to/Form
|
||||||
|
@ -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
|
Components, declare the following environment variables before running
|
||||||
PHPUnit:
|
PHPUnit:
|
||||||
|
|
||||||
export HTTP_TWIG=../path/to/Twig
|
export TWIG=../path/to/Twig
|
||||||
export HTTP_FORM=../path/to/Form
|
export SYMFONY_FORM=../path/to/Form
|
||||||
export HTTP_TRANSLATION=../path/to/Translation
|
export SYMFONY_TRANSLATION=../path/to/Translation
|
||||||
export HTTP_EVENT_DISPATCHER=../path/to/EventDispatcher
|
export SYMFONY_EVENT_DISPATCHER=../path/to/EventDispatcher
|
||||||
export HTTP_LOCALE=../path/to/Locale
|
export SYMFONY_LOCALE=../path/to/Locale
|
||||||
|
@ -14,6 +14,7 @@ services:
|
|||||||
class: FooClass
|
class: FooClass
|
||||||
calls:
|
calls:
|
||||||
- [ setBar, [] ]
|
- [ setBar, [] ]
|
||||||
|
- [ setBar ]
|
||||||
method_call2:
|
method_call2:
|
||||||
class: FooClass
|
class: FooClass
|
||||||
calls:
|
calls:
|
||||||
|
@ -26,7 +26,9 @@ class CollectionType extends AbstractType
|
|||||||
public function buildForm(FormBuilder $builder, array $options)
|
public function buildForm(FormBuilder $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($options['allow_add'] && $options['prototype']) {
|
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());
|
$builder->setAttribute('prototype', $prototype->getForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +200,6 @@ class FieldType extends AbstractType
|
|||||||
|
|
||||||
private function humanize($text)
|
private function humanize($text)
|
||||||
{
|
{
|
||||||
return ucfirst(strtolower(str_replace('_', ' ', $text)));
|
return ucfirst(trim(strtolower(preg_replace('/[_\s]+/', ' ', $text))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,4 +185,16 @@ class CollectionTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$this->assertSame('__test__', $form->getAttribute('prototype')->getName());
|
$this->assertSame('__test__', $form->getAttribute('prototype')->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPrototypeDefaultLabel()
|
||||||
|
{
|
||||||
|
$form = $this->factory->create('collection', array(), array(
|
||||||
|
'type' => 'file',
|
||||||
|
'allow_add' => true,
|
||||||
|
'prototype' => true,
|
||||||
|
'prototype_name' => '__test__',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertSame('__test__label__', $form->createView()->get('prototype')->get('label'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,22 @@ class FieldTypeTest extends TypeTestCase
|
|||||||
$this->assertSame('test', $view->get('translation_domain'));
|
$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()
|
public function testDefaultTranslationDomain()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('field');
|
$form = $this->factory->create('field');
|
||||||
|
Reference in New Issue
Block a user