/** * @covers MicrosoftAzure\Storage\Table\Models\Entity::setETag * @covers MicrosoftAzure\Storage\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 \MicrosoftAzure\Storage\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) ? EdmType::STRING : (string) $type, $isnull ? null : $value); } return $entity; }