|
@@ -40,9 +40,9 @@ class EntityChoiceListTest extends DoctrineOrmTestCase
|
|
{
|
|
{
|
|
$entity1 = new SingleIdentEntity(1, 'Foo');
|
|
$entity1 = new SingleIdentEntity(1, 'Foo');
|
|
$entity2 = new SingleIdentEntity(2, 'Bar');
|
|
$entity2 = new SingleIdentEntity(2, 'Bar');
|
|
-
|
|
|
|
|
|
+
|
|
// no persist here!
|
|
// no persist here!
|
|
-
|
|
|
|
|
|
+
|
|
$choiceList = new EntityChoiceList(
|
|
$choiceList = new EntityChoiceList(
|
|
$this->em,
|
|
$this->em,
|
|
self::SINGLE_IDENT_CLASS,
|
|
self::SINGLE_IDENT_CLASS,
|
|
@@ -53,8 +53,57 @@ class EntityChoiceListTest extends DoctrineOrmTestCase
|
|
$entity2,
|
|
$entity2,
|
|
)
|
|
)
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
// triggers loading -> exception
|
|
// triggers loading -> exception
|
|
$choiceList->getChoices();
|
|
$choiceList->getChoices();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function testFlattenedChoicesAreManaged()
|
|
|
|
+ {
|
|
|
|
+ $entity1 = new SingleIdentEntity(1, 'Foo');
|
|
|
|
+ $entity2 = new SingleIdentEntity(2, 'Bar');
|
|
|
|
+
|
|
|
|
+ // Persist for managed state
|
|
|
|
+ $this->em->persist($entity1);
|
|
|
|
+ $this->em->persist($entity2);
|
|
|
|
+
|
|
|
|
+ $choiceList = new EntityChoiceList(
|
|
|
|
+ $this->em,
|
|
|
|
+ self::SINGLE_IDENT_CLASS,
|
|
|
|
+ 'name',
|
|
|
|
+ null,
|
|
|
|
+ array(
|
|
|
|
+ $entity1,
|
|
|
|
+ $entity2,
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $this->assertSame(array(1 => 'Foo', 2 => 'Bar'), $choiceList->getChoices());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function testNestedChoicesAreManaged()
|
|
|
|
+ {
|
|
|
|
+ $entity1 = new SingleIdentEntity(1, 'Foo');
|
|
|
|
+ $entity2 = new SingleIdentEntity(2, 'Bar');
|
|
|
|
+
|
|
|
|
+ // Oh yea, we're persistin' with fire now!
|
|
|
|
+ $this->em->persist($entity1);
|
|
|
|
+ $this->em->persist($entity2);
|
|
|
|
+
|
|
|
|
+ $choiceList = new EntityChoiceList(
|
|
|
|
+ $this->em,
|
|
|
|
+ self::SINGLE_IDENT_CLASS,
|
|
|
|
+ 'name',
|
|
|
|
+ null,
|
|
|
|
+ array(
|
|
|
|
+ 'group1' => array($entity1),
|
|
|
|
+ 'group2' => array($entity2),
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $this->assertSame(array(
|
|
|
|
+ 'group1' => array(1 => 'Foo'),
|
|
|
|
+ 'group2' => array(2 => 'Bar')
|
|
|
|
+ ), $choiceList->getChoices());
|
|
|
|
+ }
|
|
}
|
|
}
|