public function testPutActionWithNestedExistingEntity()
{
$mother = new Person();
$mother->name = "Sharon Lemon";
$person = new Person();
$person->name = "Stan Lemon";
$person->mother = $mother;
$this->em->persist($person);
$this->em->flush($person);
$this->em->clear();
$request = $this->makeRequest('PUT', '/person/' . $person->id, json_encode(array('name' => $person->name, 'mother' => array('id' => $mother->id, 'name' => $mother->name))));
$this->controller->putAction($request, 'person', $person->id);
$refresh = $this->em->getRepository('Lemon\\RestBundle\\Tests\\Fixtures\\Person')->findOneBy(array('id' => $person->id));
$this->assertNotNull($refresh);
$this->assertEquals($person->id, $refresh->id);
$this->assertEquals($person->name, $refresh->name);
$this->assertNotNull($refresh->mother);
$this->assertEquals($person->mother->id, $refresh->mother->id);
$this->assertEquals($person->mother->name, $refresh->mother->name);
}