merged branch bschussek/issue5113-2.3 (PR #8981)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3][Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted Same as #7940, rebased onto 2.3. Commits -------7879f07
[DoctrineBridge] Improved test coverage of EntityChoiceList58e7c10
[Form] Improved test coverage of ChoiceList classes9542d72
[Form] Fixed expanded choice field to be marked invalid when unknown choices are submitted72b8807
[Form] Fixed ChoiceList::get*By*() methods to preserve order and array keyse1bf07f
[Form] Removed usage of the ChoiceList::getIndicesFor*() methods where they don't offer any performance benefit
This commit is contained in:
commit
51413e1cbe
@ -51,7 +51,7 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
if (!class_exists('Doctrine\ORM\EntityManager')) {
|
if (!class_exists('Doctrine\ORM\EntityManager')) {
|
||||||
$this->markTestSkipped('Doctrine ORM is not available.');
|
$this->markTestSkipped('Doctrine ORM is not available.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em = DoctrineTestHelper::createTestEntityManager();
|
$this->em = DoctrineTestHelper::createTestEntityManager();
|
||||||
|
|
||||||
$schemaTool = new SchemaTool($this->em);
|
$schemaTool = new SchemaTool($this->em);
|
||||||
@ -110,7 +110,7 @@ class GenericEntityChoiceListTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Form\Exception\FormException
|
* @expectedException \Symfony\Component\Form\Exception\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function testChoicesMustBeManaged()
|
public function testChoicesMustBeManaged()
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\Type;
|
|||||||
|
|
||||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
|
use Symfony\Component\Form\Test\TypeTestCase;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
|
||||||
@ -22,7 +23,6 @@ use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
|
|||||||
use Doctrine\ORM\Tools\SchemaTool;
|
use Doctrine\ORM\Tools\SchemaTool;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||||
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
|
|
||||||
|
|
||||||
class EntityTypeTest extends TypeTestCase
|
class EntityTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->placeholderPresent) {
|
if ($this->placeholderPresent) {
|
||||||
$values['placeholder'] = false === $index;
|
$values['placeholder'] = 0 === count($valueMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
|
@ -114,23 +114,23 @@ class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
|||||||
$this->assertNull($form->getViewData());
|
$this->assertNull($form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBindWithEmptyValueAndFalseUnchecked()
|
public function testSubmitWithEmptyValueAndFalseUnchecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('checkbox', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->bind(false);
|
$form->submit(false);
|
||||||
|
|
||||||
$this->assertFalse($form->getData());
|
$this->assertFalse($form->getData());
|
||||||
$this->assertNull($form->getViewData());
|
$this->assertNull($form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBindWithEmptyValueAndTrueChecked()
|
public function testSubmitWithEmptyValueAndTrueChecked()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('checkbox', null, array(
|
$form = $this->factory->create('checkbox', null, array(
|
||||||
'value' => '',
|
'value' => '',
|
||||||
));
|
));
|
||||||
$form->bind(true);
|
$form->submit(true);
|
||||||
|
|
||||||
$this->assertTrue($form->getData());
|
$this->assertTrue($form->getData());
|
||||||
$this->assertSame('', $form->getViewData());
|
$this->assertSame('', $form->getViewData());
|
||||||
|
Reference in New Issue
Block a user