/** * @covers WindowsAzure\ServiceRuntime\Internal\RoleInstance::__construct * @covers WindowsAzure\ServiceRuntime\Internal\RoleInstance::getId */ public function testGetId() { $id = 'roleId'; // Setup $roleInstance = new RoleInstance($id, null, null, null); // Test $this->assertEquals($id, $roleInstance->getId()); }
/** * 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; }