/**
  * @covers WindowsAzure\Blob\Models\CreateBlobSnapshotResult::getLastModified
  * @covers WindowsAzure\Blob\Models\CreateBlobSnapshotResult::setLastModified
  */
 public function testSetLastModified()
 {
     $createBlobSnapshotResult = new CreateBlobSnapshotResult();
     $expected = new \DateTime("2008-8-8");
     $createBlobSnapshotResult->setLastModified($expected);
     $this->assertEquals($expected, $createBlobSnapshotResult->getLastModified());
 }
 /**
  * Creates CreateBlobSnapshotResult object from the response of the 
  * create Blob snapshot request.
  * 
  * @param array $headers The HTTP response headers in array representation.
  * 
  * @return CreateBlobSnapshotResult
  */
 public static function create($headers)
 {
     $result = new CreateBlobSnapshotResult();
     $headerWithLowerCaseKey = array_change_key_case($headers);
     $result->setEtag($headerWithLowerCaseKey[Resources::ETAG]);
     $result->setLastModified(Utilities::rfc1123ToDateTime($headerWithLowerCaseKey[Resources::LAST_MODIFIED]));
     $result->setSnapshot($headerWithLowerCaseKey[Resources::X_MS_SNAPSHOT]);
     return $result;
 }
Exemple #3
0
 /**
  * Creates a snapshot of a blob.
  * 
  * @param string                           $container The name of the container.
  * @param string                           $blob      The name of the blob.
  * @param Models\CreateBlobSnapshotOptions $options   The optional parameters.
  * 
  * @return Models\CreateBlobSnapshotResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691971.aspx
  */
 public function createBlobSnapshot($container, $blob, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $this->_createPath($container, $blob);
     $expectedStatusCode = Resources::STATUS_CREATED;
     if (is_null($options)) {
         $options = new CreateBlobSnapshotOptions();
     }
     $queryParams[Resources::QP_COMP] = 'snapshot';
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $headers = $this->addMetadataHeaders($headers, $options->getMetadata());
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $expectedStatusCode);
     return CreateBlobSnapshotResult::create($response->getHeader());
 }