/**
  * @covers WindowsAzure\Blob\Models\AccessCondition::ifNotModifiedSince
  * @covers WindowsAzure\Blob\Models\AccessCondition::getHeader
  * @covers WindowsAzure\Blob\Models\AccessCondition::getValue
  */
 public function testIfNotModifiedSince()
 {
     // Setup
     $expectedHeader = Resources::IF_UNMODIFIED_SINCE;
     $expectedValue = new \DateTime('Sun, 25 Sep 2011 00:42:49 GMT');
     // Test
     $actual = AccessCondition::ifNotModifiedSince($expectedValue);
     // Assert
     $this->assertEquals($expectedHeader, $actual->getHeader());
     $this->assertEquals($expectedValue, $actual->getValue());
 }
 public static function getInterestingDeleteContainerOptions()
 {
     $ret = array();
     $past = new \DateTime("01/01/2010");
     $future = new \DateTime("01/01/2020");
     $options = new DeleteContainerOptions();
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setTimeout(10);
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setTimeout(-10);
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setAccessCondition(AccessCondition::ifModifiedSince($past));
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setAccessCondition(AccessCondition::ifNotModifiedSince($past));
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setAccessCondition(AccessCondition::ifModifiedSince($future));
     array_push($ret, $options);
     $options = new DeleteContainerOptions();
     $options->setAccessCondition(AccessCondition::ifNotModifiedSince($future));
     array_push($ret, $options);
     return $ret;
 }
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::createPageBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlob
  * @covers WindowsAzure\Blob\BlobRestProxy::getBlobProperties
  * @covers WindowsAzure\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');
     }
 }