/**
  * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobOptions::setAccessCondition
  */
 public function testSetAccessCondition()
 {
     // Setup
     $expected = AccessCondition::none();
     $result = new GetBlobOptions();
     // Test
     $result->setAccessCondition($expected);
     // Assert
     $this->assertEquals($expected, $result->getAccessCondition());
 }
 public static function getGetBlobOptions()
 {
     $ret = array();
     $options = new GetBlobOptions();
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setTimeout(10);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setTimeout(-10);
     array_push($ret, $options);
     // Get Blob only supports the temporal access conditions.
     foreach (self::getTemporalAccessConditions() as $ac) {
         $options = new GetBlobOptions();
         $options->setAccessCondition($ac);
         array_push($ret, $options);
     }
     $options = new GetBlobOptions();
     $options->setRangeStart(50);
     $options->setRangeEnd(200);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setRangeStart(50);
     $options->setRangeEnd(200);
     $options->setComputeRangeMD5(true);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setRangeStart(50);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setComputeRangeMD5(true);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setRangeEnd(200);
     $options->setComputeRangeMD5(true);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setRangeEnd(200);
     array_push($ret, $options);
     $options = new GetBlobOptions();
     $options->setSnapshot('placeholder');
     array_push($ret, $options);
     // TODO: Handle Lease ID
     //        $options = new GetBlobOptions();
     //        $options->setLeaseId('setLeaseId');
     //        array_push($ret, $options);
     return $ret;
 }
 /**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobMetadata
  */
 public function testGetBlobWithIfNotModifiedSinceAccessConditionWorks()
 {
     // Act
     $container = self::$_test_container_for_blobs;
     $blob = 'test';
     $this->restProxy->createPageBlob($container, $blob, 4096);
     $props = $this->restProxy->getBlobProperties($container, $blob);
     // To test for "IfNotModifiedSince", we need to make updates to the blob
     // until at least 1 second has passed since the blob creation
     $lastModifiedBase = $props->getProperties()->getLastModified();
     // +1 second
     $lastModifiedNext = clone $lastModifiedBase;
     $lastModifiedNext = $lastModifiedNext->modify("+1 sec");
     while (true) {
         $metadata = array('test' => 'test1');
         $result = $this->restProxy->setBlobMetadata($container, $blob, $metadata);
         if ($result->getLastModified() >= $lastModifiedNext) {
             break;
         }
     }
     try {
         $opts = new GetBlobOptions();
         $opts->setAccessCondition(AccessCondition::ifNotModifiedSince($lastModifiedBase));
         $this->restProxy->getBlob($container, $blob, $opts);
         $this->fail('getBlob should throw an exception');
     } catch (ServiceException $e) {
         $this->assertEquals(TestResources::STATUS_PRECONDITION_FAILED, $e->getCode(), 'got the expected exception');
     }
 }