public function testSerializeEmbeddedDiscriminator() { $apple = new Apple(); $apple->setVariety('granny smith'); $orange = new Orange(); $orange->setVariety('naval'); $fruitBowl = new FruitBowl(); $fruitBowl->setEmbeddedFruit(new ArrayCollection([$apple, $orange])); $correct = array('embeddedFruit' => [['_doctrine_class_name' => 'apple', 'variety' => 'granny smith', 'type' => 'apple'], ['_doctrine_class_name' => 'orange', 'variety' => 'naval', 'type' => 'orange']]); $array = $this->serializer->toArray($fruitBowl); $this->assertEquals($correct, $array); }