/**
  * @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());
 }
Example #2
0
 /**
  * Creates a new container in the given storage account.
  * 
  * @param string                        $container The container name.
  * @param Models\DeleteContainerOptions $options   The optional parameters.
  * 
  * @return none
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179408.aspx
  */
 public function deleteContainer($container, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::notNullOrEmpty($container, 'container');
     $method = Resources::HTTP_DELETE;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $container;
     $statusCode = Resources::STATUS_ACCEPTED;
     if (is_null($options)) {
         $options = new DeleteContainerOptions();
     }
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_REST_TYPE, 'container');
     $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
 }
 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::createContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::deleteContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::listContainers
  */
 private function deleteContainerWorker($options)
 {
     $container = BlobServiceFunctionalTestData::getInterestingContainerName();
     // Make sure there is something to delete.
     $this->restProxy->createContainer($container);
     // Make sure that the list of all applicable containers is correctly updated.
     $opts = new ListContainersOptions();
     $opts->setPrefix(BlobServiceFunctionalTestData::$testUniqueId);
     $qs = $this->restProxy->listContainers($opts);
     $this->assertEquals(count($qs->getContainers()), count(BlobServiceFunctionalTestData::$TEST_CONTAINER_NAMES) + 1, 'After adding one, with Prefix=(\'' . BlobServiceFunctionalTestData::$testUniqueId . '\'), then Containers length');
     $deleted = false;
     try {
         if (is_null($options)) {
             $this->restProxy->deleteContainer($container);
         } else {
             $this->restProxy->deleteContainer($container, $options);
         }
         $deleted = true;
         if (is_null($options)) {
             $options = new DeleteContainerOptions();
         }
         if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) {
             $this->assertTrue(false, 'Expect negative timeouts in $options to throw');
         }
         if (!Configuration::isEmulated() && !BlobServiceFunctionalTestData::passTemporalAccessCondition($options->getAccessCondition())) {
             $this->assertTrue(false, 'Failing access condition should throw');
         }
         // Make sure that the list of all applicable containers is correctly updated.
         $opts = new ListContainersOptions();
         $opts->setPrefix(BlobServiceFunctionalTestData::$testUniqueId);
         $qs = $this->restProxy->listContainers($opts);
         $this->assertEquals(count($qs->getContainers()), count(BlobServiceFunctionalTestData::$TEST_CONTAINER_NAMES), 'After adding then deleting one, with Prefix=(\'' . BlobServiceFunctionalTestData::$testUniqueId . '\'), then Containers length');
         // Nothing else interesting to check for the $options.
     } catch (ServiceException $e) {
         if (is_null($options)) {
             $options = new DeleteContainerOptions();
         }
         if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) {
             $this->assertEquals(500, $e->getCode(), 'getCode');
         } else {
             if (!Configuration::isEmulated() && !BlobServiceFunctionalTestData::passTemporalAccessCondition($options->getAccessCondition())) {
                 $this->assertEquals(412, $e->getCode(), 'getCode');
             } else {
             }
         }
     }
     if (!$deleted) {
         // Try again. If it does not work, not much else to try.
         $this->restProxy->deleteContainer($container);
     }
 }