/** * @covers WindowsAzure\ServiceManagement\Models\AffinityGroup::toArray * @covers WindowsAzure\ServiceManagement\Models\AffinityGroup::__construct */ public function testSerialize() { // Setup $serializer = new XmlSerializer(); $expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $expected .= '<CreateService xmlns="http://schemas.microsoft.com/windowsazure">' . "\n"; $expected .= ' <Name>Name</Name>' . "\n"; $expected .= ' <Label>Label</Label>' . "\n"; $expected .= ' <Description>Description</Description>' . "\n"; $expected .= ' <Location>Location</Location>' . "\n"; $expected .= '</CreateService>' . "\n"; $affinitygroup = new AffinityGroup(); $affinitygroup->setName('Name'); $affinitygroup->setLabel('Label'); $affinitygroup->setLocation('Location'); $affinitygroup->setDescription('Description'); $affinitygroup->addSerializationProperty(XmlSerializer::ROOT_NAME, 'CreateService'); // Test $actual = $affinitygroup->serialize($serializer); // Assert $this->assertEquals($expected, $actual); }
/** * Updates the label and/or the description for an affinity group for the * specified subscription. * * @param string $name The affinity group name. * @param string $label The affinity group label. * @param Models\CreateAffinityGroupOptions $options The optional parameters. * * @return none * * @see http://msdn.microsoft.com/en-us/library/windowsazure/gg715316.aspx */ public function updateAffinityGroup($name, $label, $options = null) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); Validate::isString($label, 'label'); Validate::notNullOrEmpty($label, 'label'); if (is_null($options)) { $options = new CreateAffinityGroupOptions(); } $affinityGroup = new AffinityGroup(); $affinityGroup->setLabel($label); $affinityGroup->setDescription($options->getDescription()); $affinityGroup->addSerializationProperty(XmlSerializer::ROOT_NAME, 'UpdateAffinityGroup'); $context = new HttpCallContext(); $context->setMethod(Resources::HTTP_PUT); $context->setPath($this->_getAffinityGroupPath($name)); $context->addStatusCode(Resources::STATUS_OK); $context->setBody($affinityGroup->serialize($this->dataSerializer)); $context->addHeader(Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE); $this->sendContext($context); }