public function testPostActionWithNestedEntity() { $request = $this->makeRequest('POST', '/person', json_encode(array('name' => 'Stan Lemon', 'mother' => array('name' => 'Sharon Lemon')))); /** @var \Symfony\Component\HttpFoundation\Response $response */ $response = $this->controller->postAction($request, 'person'); $this->em->clear(); $data = json_decode($response->getContent()); $this->assertEquals($data->name, "Stan Lemon"); $refresh = $this->em->getRepository('Lemon\\RestBundle\\Tests\\Fixtures\\Person')->findOneBy(array('id' => $data->id)); // If I don't do this, Doctrine ORM 2.3 has null's in all the properties of mother - seems to be a bug // as it is not an issues with 2.4 and later $this->em->refresh($refresh); $this->assertNotNull($refresh); $this->assertEquals("Stan Lemon", $refresh->name); $this->assertNotNull($refresh->mother); $this->assertEquals("Sharon Lemon", $refresh->mother->name); }