Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: symfony/symfony
base: 2.7
...
head fork: mvrhov/symfony
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 02, 2012
@mvrhov mvrhov Testcase for #3539 a1cecef
Showing with 110 additions and 0 deletions.
  1. +110 −0 src/Symfony/Component/Form/Tests/Util/PropertyPathCollectionTest.php
View
110 src/Symfony/Component/Form/Tests/Util/PropertyPathCollectionTest.php
@@ -14,6 +14,11 @@
use Symfony\Component\Form\Util\PropertyPath;
use Symfony\Component\Form\Tests\Fixtures\Author;
use Symfony\Component\Form\Tests\Fixtures\Magician;
+use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\Extension\Core\CoreExtension;
+use Symfony\Component\Form\FormFactory;
+use Symfony\Component\Form\AbstractType;
+use Doctrine\Common\Collections\ArrayCollection;
class PropertyPathCollectionTest_Car
{
@@ -66,6 +71,71 @@ public function removeAxis($axis) {}
public function getAxes() {}
}
+class PropertyPathCollectionTest_CarAxes
+{
+ private $axes;
+
+ public function addAxis(PropertyPathCollectionTest_CarAxis $axis)
+ {
+ //we are not checking if it's already in collection on purpose
+ //if (!$this->getAxes()->contains($axis)) {
+ $this->getAxes()->add($axis);
+ $axis->setCar($this);
+ //}
+ }
+
+ public function removeAxis(PropertyPathCollectionTest_CarAxis $axis)
+ {
+ $this->getAxes()->removeElement($axis);
+ }
+
+ public function getAxes()
+ {
+ return $this->axes ?: $this->axes = new ArrayCollection();
+ }
+}
+
+class PropertyPathCollectionTest_CarAxis
+{
+ private $car;
+
+ public $prop1;
+ public $prop2;
+
+ public function setCar($car)
+ {
+ $this->car = $car;
+ }
+
+ public function getCar()
+ {
+ return $this->car;
+ }
+}
+
+class PropertyPathCollectionTest_CarAxisType extends AbstractType
+{
+ public function buildForm(FormBuilder $builder, array $options)
+ {
+ $builder
+ ->add('prop1', 'text')
+ ->add('prop2', 'text')
+ ;
+ }
+
+ public function getName()
+ {
+ return 'axis';
+ }
+
+ public function getDefaultOptions()
+ {
+ return array(
+ 'data_class' => __NAMESPACE__ .'\\PropertyPathCollectionTest_CarAxis',
+ );
+ }
+}
+
abstract class PropertyPathCollectionTest extends \PHPUnit_Framework_TestCase
{
abstract protected function getCollection(array $array);
@@ -182,4 +252,44 @@ public function testMapFormToDataFailsIfOnlyRemoverFound()
$path->setValue($car, $axesAfter);
}
+
+ public function testDoubles()
+ {
+ $ff = new FormFactory(array(new CoreExtension()));
+
+ $axes = new PropertyPathCollectionTest_CarAxes();
+ $builder = $ff->createBuilder('form', $axes);
+ $builder
+ ->add('axes', 'collection', array(
+ 'type' => new PropertyPathCollectionTest_CarAxisType(),
+ 'allow_add' => true,
+ )
+ )
+ ;
+
+ $builder
+ ->getForm()
+ ->bind(
+ array('axes' => array(
+ array('prop1' => '01', 'prop2' => '02'),
+ array('prop1' => '11', 'prop2' => '12'),
+ )
+ )
+ );
+
+ $newAxis = function($prop1, $prop2) {
+ $ret = new PropertyPathCollectionTest_CarAxis();
+ $ret->prop1 = $prop1;
+ $ret->prop2 = $prop2;
+
+ return $ret;
+ };
+
+ $cmpAxes = new PropertyPathCollectionTest_CarAxes();
+ $cmpAxes->addAxis($newAxis('01', '02'));
+ $cmpAxes->addAxis($newAxis('11', '12'));
+
+ $this->assertEquals($cmpAxes->getAxes()->count(), $axes->getAxes()->count());
+ $this->assertEquals($cmpAxes, $axes);
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.