Esempio n. 1
0
 public function testDeleteAttributes()
 {
     $domainName = $this->_testDomainNamePrefix . '_testDeleteAttributes';
     $this->_amazon->deleteDomain($domainName);
     $this->_amazon->createDomain($domainName);
     try {
         $itemName = $this->_testItemNamePrefix . '_testDeleteAttributes';
         $attributeName1 = $this->_testAttributeNamePrefix . '_testDeleteAttributes1';
         $attributeName2 = $this->_testAttributeNamePrefix . '_testDeleteAttributes2';
         $attributeName3 = $this->_testAttributeNamePrefix . '_testDeleteAttributes3';
         $attributeName4 = $this->_testAttributeNamePrefix . '_testDeleteAttributes4';
         $attributeValue1 = 'value1';
         $attributeValue2 = 'value2';
         $attributeValue3 = 'value3';
         $attributeValue4 = 'value4';
         $attributes = array(new SimpleDb\Attribute($itemName, $attributeName1, $attributeValue1), new SimpleDb\Attribute($itemName, $attributeName2, $attributeValue2), new SimpleDb\Attribute($itemName, $attributeName3, $attributeValue3), new SimpleDb\Attribute($itemName, $attributeName4, $attributeValue4));
         // Now that everything's set up, test it
         $this->_amazon->putAttributes($domainName, $itemName, $attributes);
         $this->_wait();
         $results = $this->_amazon->getAttributes($domainName, $itemName);
         $this->assertEquals(4, count($results));
         $this->assertTrue(array_key_exists($attributeName1, $results));
         $this->assertTrue(array_key_exists($attributeName2, $results));
         $this->assertTrue(array_key_exists($attributeName3, $results));
         $this->assertTrue(array_key_exists($attributeName4, $results));
         $this->assertEquals($attributeValue1, current($results[$attributeName1]->getValues()));
         $this->assertEquals($attributeValue2, current($results[$attributeName2]->getValues()));
         $this->assertEquals($attributeValue3, current($results[$attributeName3]->getValues()));
         $this->assertEquals($attributeValue4, current($results[$attributeName4]->getValues()));
         $this->_amazon->deleteAttributes($domainName, $itemName, array($attributes[0]));
         $this->_wait();
         $results = $this->_amazon->getAttributes($domainName, $itemName);
         $this->assertEquals(3, count($results));
         $this->assertTrue(array_key_exists($attributeName2, $results));
         $this->assertTrue(array_key_exists($attributeName3, $results));
         $this->assertTrue(array_key_exists($attributeName4, $results));
         $this->assertEquals($attributeValue2, current($results[$attributeName2]->getValues()));
         $this->assertEquals($attributeValue3, current($results[$attributeName3]->getValues()));
         $this->assertEquals($attributeValue4, current($results[$attributeName4]->getValues()));
         $this->_amazon->deleteAttributes($domainName, $itemName, array($attributes[1], $attributes[2]));
         $this->_wait();
         $results = $this->_amazon->getAttributes($domainName, $itemName);
         $this->assertEquals(1, count($results));
         $this->assertTrue(array_key_exists($attributeName4, $results));
         $this->assertEquals($attributeValue4, current($results[$attributeName4]->getValues()));
         $this->_amazon->deleteAttributes($domainName, $itemName, array($attributes[3]));
         $this->_wait();
         $results = $this->_amazon->getAttributes($domainName, $itemName);
         $this->assertEquals(0, count($results));
         $this->_amazon->deleteDomain($domainName);
     } catch (Exception $e) {
         $this->_amazon->deleteDomain($domainName);
         throw $e;
     }
 }
Esempio n. 2
0
 /**
  * Delete document.
  *
  * @param  string $collectionName Collection from which to delete document
  * @param  mixed  $document Document ID or Document object.
  * @param  array  $options
  * @return boolean
  */
 public function deleteDocument($collectionName, $document, $options = null)
 {
     if ($document instanceof Zend\Cloud\DocumentService\Document) {
         $document = $document->getId();
     }
     try {
         $this->_simpleDb->deleteAttributes($collectionName, $document);
     } catch (Zend\Service\Amazon\Exception $e) {
         throw new Exception\RuntimeException('Error on document deletion: ' . $e->getMessage(), $e->getCode(), $e);
     }
     return true;
 }