/**
  * @covers WindowsAzure\Blob\Models\CopyBlobOptions::setSourceAccessCondition
  * @covers WindowsAzure\Blob\Models\CopyBlobOptions::getSourceAccessCondition
  */
 public function testSetSourceAccessCondition()
 {
     $copyBlobOptions = new CopyBlobOptions();
     $expected = AccessCondition::IfMatch("x");
     $copyBlobOptions->setSourceAccessCondition($expected);
     $this->assertEquals($expected, $copyBlobOptions->getSourceAccessCondition());
 }
 /**
  * @covers WindowsAzure\Blob\Models\SetContainerMetadataOptions::setAccessCondition
  */
 public function testSetAccessCondition()
 {
     // Setup
     $expected = AccessCondition::none();
     $result = new SetContainerMetadataOptions();
     // Test
     $result->setAccessCondition($expected);
     // Assert
     $this->assertEquals($expected, $result->getAccessCondition());
 }
 /**
  * @covers WindowsAzure\Blob\Models\CreateBlobPagesOptions::setAccessCondition
  */
 public function testSetAccessCondition()
 {
     // Setup
     $expected = AccessCondition::none();
     $options = new CreateBlobPagesOptions();
     // Test
     $options->setAccessCondition($expected);
     // Assert
     $this->assertEquals($expected, $options->getAccessCondition());
 }
 /**
  * @covers WindowsAzure\Blob\Models\GetBlobPropertiesOptions::setAccessCondition
  */
 public function testSetAccessCondition()
 {
     // Setup
     $expected = AccessCondition::none();
     $result = new GetBlobPropertiesOptions();
     // Test
     $result->setAccessCondition($expected);
     // Assert
     $this->assertEquals($expected, $result->getAccessCondition());
 }
 /**
  * @covers WindowsAzure\Blob\Models\DeleteContainerOptions::setAccessCondition
  */
 public function testSetAccessCondition()
 {
     // Setup
     $expected = AccessCondition::none();
     $options = new DeleteContainerOptions();
     // Test
     $options->setAccessCondition($expected);
     // Assert
     $this->assertEquals($expected, $options->getAccessCondition());
 }
 /**
  * Sets header type
  * 
  * @param string $headerType can be one of Resources
  * 
  * @return none.
  */
 public function setHeader($headerType)
 {
     $valid = AccessCondition::isValid($headerType);
     Validate::isTrue($valid, Resources::INVALID_HT_MSG);
     $this->_header = $headerType;
 }
 /**
  * @covers  WindowsAzure\Common\Internal\ServiceRestProxy::addOptionalSourceAccessConditionHeader
  * @depends test__construct
  */
 public function testAddOptionalSourceAccessContitionHeader($restRestProxy)
 {
     // Setup
     $expectedHeader = Resources::X_MS_SOURCE_IF_MATCH;
     $expectedValue = '0x8CAFB82EFF70C46';
     $accessCondition = AccessCondition::ifMatch($expectedValue);
     $headers = array('Header1' => 'Value1', 'Header2' => 'Value2');
     // Test
     $actual = $restRestProxy->addOptionalSourceAccessConditionHeader($headers, $accessCondition);
     // Assert
     $this->assertCount(3, $actual);
     $this->assertEquals($expectedValue, $actual[$expectedHeader]);
 }
 /**
  * Constructs the access condition object with none option. 
  */
 public function __construct()
 {
     $this->_accessCondition = AccessCondition::none();
 }
 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\Models\AccessCondition::isValid
  */
 public function testIsValidWithInvalid()
 {
     // Test
     $actual = AccessCondition::isValid('1234');
     // Assert
     $this->assertFalse($actual);
 }
 /**
  * @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');
     }
 }