/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage A single selection must be passed a single value not a collection. Make sure that form option "multiple=false" is set for many-to-one relation and "multiple=true" is set for many-to-many or one-to-many relations. */ public function testTransformEntityException() { $entity1 = new Foo(); $entity1->setBar('foo'); $entity2 = new Foo(); $entity2->setBar('bar'); $entity3 = new Foo(); $entity3->setBar('baz'); $collection = new ArrayCollection(); $collection[] = $entity1; $collection[] = $entity2; $collection[] = $entity3; $transformer = new ModelToIdPropertyTransformer($this->modelManager, 'Sonata\\AdminBundle\\Tests\\Fixtures\\Entity\\Foo', 'bar', false); $transformer->transform($collection); }