/**
  * @covers MicrosoftAzure\Storage\Table\Models\GetEntityResult::setEntity
  * @covers MicrosoftAzure\Storage\Table\Models\GetEntityResult::getEntity
  */
 public function testSetEntity()
 {
     // Setup
     $result = new GetEntityResult();
     $entity = new Entity();
     // Test
     $result->setEntity($entity);
     // Assert
     $this->assertEquals($entity, $result->getEntity());
 }
예제 #2
0
 /**
  * Gets table entity.
  *
  * @param string                     $table        The name of the table.
  * @param string                     $partitionKey The entity partition key.
  * @param string                     $rowKey       The entity row key.
  * @param Models\TableServiceOptions $options      The optional parameters.
  *
  * @return Models\GetEntityResult
  *
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx
  */
 public function getEntity($table, $partitionKey, $rowKey, $options = null)
 {
     Validate::isString($table, 'table');
     Validate::notNullOrEmpty($table, 'table');
     Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG);
     Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG);
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_OK;
     $path = $this->_getEntityPath($table, $partitionKey, $rowKey);
     if (is_null($options)) {
         $options = new TableServiceOptions();
     }
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $context = new HttpCallContext();
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->addStatusCode($statusCode);
     $response = $this->sendContext($context);
     $entity = $this->_atomSerializer->parseEntity($response->getBody());
     $result = new GetEntityResult();
     $result->setEntity($entity);
     return $result;
 }