/** * @covers WindowsAzure\Table\Models\Entity::setEtag * @covers WindowsAzure\Table\Models\Entity::getEtag */ public function testSetEtag() { // Setup $expected = '0x8CAFB82EFF70C46'; $entity = new Entity(); $entity->setEtag($expected); // Test $entity->setEtag($expected); // Assert $this->assertEquals($expected, $entity->getEtag()); }
static function cloneEntity($initialEnt) { $ret = new Entity(); $initialProps = $initialEnt->getProperties(); $retProps = array(); foreach ($initialProps as $propName => $initialProp) { // Don't mess with the timestamp. if ($propName == 'Timestamp') { continue; } $retProp = new Property(); $retProp->setEdmType($initialProp->getEdmType()); $retProp->setValue($initialProp->getValue()); $retProps[$propName] = $retProp; } $ret->setProperties($retProps); $ret->setEtag($initialEnt->getEtag()); return $ret; }
/** * Parses an entity entry from given SimpleXML object. * * @param \SimpleXML $result The SimpleXML object representing the entity. * * @return \WindowsAzure\Table\Models\Entity */ private function _parseOneEntity($result) { $prefix = $this->_dataServicesMetadataPrefix; $prop = $result->content->xpath(".//{$prefix}:properties"); $prop = $prop[0]->children($this->_dataServicesNamespaceName); $entity = new Entity(); // Set Etag $etag = $result->attributes($this->_dataServicesMetadataNamespaceName); $etag = $etag[Resources::ETAG]; $entity->setEtag((string) $etag); foreach ($prop as $key => $value) { $attributes = $value->attributes($this->_dataServicesMetadataNamespaceName); $type = $attributes['type']; $isnull = $attributes['null']; $value = EdmType::unserializeQueryValue((string) $type, $value); $entity->addProperty((string) $key, is_null($type) ? null : (string) $type, $isnull ? null : $value); } return $entity; }