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; } }
/** * Fetch single document by ID * * @param string $collectionName Collection name * @param mixed $documentId Document ID, adapter-dependent * @param array $options * @return Zend\Cloud\DocumentService\Document */ public function fetchDocument($collectionName, $documentId, $options = null) { try { $attributes = $this->_simpleDb->getAttributes($collectionName, $documentId); if ($attributes == false || count($attributes) == 0) { return false; } return $this->_resolveAttributes($attributes, true); } catch (Zend\Service\Amazon\Exception $e) { throw new Exception\RunTimeException('Error on fetching document: ' . $e->getMessage(), $e->getCode(), $e); } }