/**
  * Translates the roles.
  * 
  * @param string       $environmentInfo The role environment info.
  * @param RoleInstance $currentInstance The current instance info.
  * @param string       $currentRole     The current role.
  * 
  * @return array
  */
 private function _translateRoles($environmentInfo, $currentInstance, $currentRole)
 {
     $rolesMap = array();
     $rolesInfo = Utilities::tryGetKeysChainValue($environmentInfo, 'Roles', 'Role');
     if (!is_null($rolesInfo)) {
         if (array_key_exists('@attributes', $rolesInfo)) {
             $rolesInfo = array(0 => $rolesInfo);
         }
         foreach ($rolesInfo as $roleInfo) {
             $roleInstances = $this->_translateRoleInstances($roleInfo);
             if ($roleInfo['@attributes']['name'] == $currentRole) {
                 $roleInstances[$currentInstance->getId()] = $currentInstance;
             }
             $role = new Role($roleInfo['@attributes']['name'], $roleInstances);
             foreach ($roleInstances as $instance) {
                 $instance->setRole($role);
             }
             $rolesMap[$roleInfo['@attributes']['name']] = $role;
         }
     }
     if (!array_key_exists($currentRole, $rolesMap)) {
         $roleInstances = array();
         $roleInstances[$currentInstance->getId()] = $currentInstance;
         $singleRole = new Role($currentRole, $roleInstances);
         $currentInstance->setRole($singleRole);
         $rolesMap[$currentRole] = $singleRole;
     }
     return $rolesMap;
 }
 /**
  * @covers WindowsAzure\ServiceRuntime\Internal\RoleInstance::getRole
  * @covers WindowsAzure\ServiceRuntime\Internal\RoleInstance::setRole
  */
 public function testGetSetRole()
 {
     $role = new Role(null, array());
     // Setup
     $roleInstance = new RoleInstance(null, null, null, null);
     // Test
     $roleInstance->setRole($role);
     $this->assertEquals($role, $roleInstance->getRole());
 }