/**
  * Test set Azure values
  */
 public function testSetAzureValues()
 {
     $values = array('PartitionKey' => 'partition1', 'RowKey' => '000001', 'Name' => 'Maarten', 'Age' => 25, 'Visible' => true);
     $target = new DynamicTableEntity();
     $target->setAzureValues($values);
     $target->setAzurePropertyType('Age', 'Edm.Int32');
     $this->assertEquals('partition1', $target->getPartitionKey());
     $this->assertEquals('000001', $target->getRowKey());
     $this->assertEquals('Maarten', $target->Name);
     $this->assertEquals(25, $target->Age);
     $this->assertEquals('Edm.Int32', $target->getAzurePropertyType('Age'));
     $this->assertEquals(true, $target->Visible);
 }
Esempio n. 2
0
 /**
  * Update document.
  *
  * The new document is merged the existing document.
  *
  * @param  string $collectionName
  * @param  mixed|\Zend\Cloud\DocumentService\Document $documentId Document identifier or document containing updates
  * @param  null|array|\Zend\Cloud\DocumentService\Document Fields to update (or new fields))
  * @param  array $options
  * @return boolean
  */
 public function updateDocument($collectionName, $documentId, $fieldset = null, $options = null)
 {
     if (null === $fieldset && $documentId instanceof \Zend\Cloud\DocumentService\Document) {
         $fieldset = $documentId->getFields();
         $documentId = $documentId->getId();
     } elseif ($fieldset instanceof \Zend\Cloud\DocumentService\Document) {
         if ($documentId == null) {
             $documentId = $fieldset->getId();
         }
         $fieldset = $fieldset->getFields();
     }
     $this->_validateCompositeKey($documentId, $collectionName);
     $this->_validateFields($fieldset);
     try {
         $entity = new DynamicTableEntity($documentId[0], $documentId[1]);
         // Ensure timestamp is set correctly
         if (isset($fieldset[self::TIMESTAMP_KEY])) {
             $entity->setTimestamp($fieldset[self::TIMESTAMP_KEY]);
             unset($fieldset[self::TIMESTAMP_KEY]);
         }
         $entity->setAzureValues($fieldset, true);
         if (isset($options[self::VERIFY_ETAG])) {
             $entity->setEtag($options[self::VERIFY_ETAG]);
         }
         $this->_storageClient->mergeEntity($collectionName, $entity, isset($options[self::VERIFY_ETAG]));
     } catch (WindowsAzureException\ExceptionInterface $e) {
         throw new Exception\RuntimeException('Error on document update: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }