/**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteContainer
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers
  */
 public function setUp()
 {
     parent::setUp();
     $settings = StorageServiceSettings::createFromConnectionString($this->connectionString);
     $accountName = $settings->getBlobEndpointUri();
     $firstSlash = strpos($accountName, '/');
     $accountName = substr($accountName, $firstSlash + 2);
     $firstDot = strpos($accountName, '.');
     $accountName = substr($accountName, 0, $firstDot);
     BlobServiceFunctionalTestData::setupData($accountName);
     $hasRoot = false;
     foreach ($this->restProxy->listContainers()->getContainers() as $container) {
         if ($container->getName() == '$root') {
             $hasRoot = true;
             $this->safeDeleteContainerContents('$root');
         } else {
             $this->safeDeleteContainer($container->getName());
         }
     }
     foreach (BlobServiceFunctionalTestData::$testContainerNames as $name) {
         $this->safeCreateContainer($name);
     }
     if (!$hasRoot) {
         $this->safeCreateContainer('$root');
     }
     if (!self::$isOneTimeSetup) {
         self::$isOneTimeSetup = true;
     }
 }
 public static function tearDownAfterClass()
 {
     if (self::$isOneTimeSetup) {
         $integrationTestBase = new IntegrationTestBase();
         $integrationTestBase->setUp();
         if ($integrationTestBase->isEmulated()) {
             $serviceProperties = BlobServiceFunctionalTestData::getDefaultServiceProperties();
             $integrationTestBase->restProxy->setServiceProperties($serviceProperties);
         }
         self::$isOneTimeSetup = false;
     }
     parent::tearDownAfterClass();
 }
 private function verifyCopyBlobWorker($options, $blobs, $getBlobResult, $sourceDataSize, $metadata)
 {
     $this->assertEquals(2, count($blobs), 'Should end up with 2 blob with same name as dest blob, snapshot and copied blob');
     $this->assertEquals($sourceDataSize, $getBlobResult->getProperties()->getContentLength(), 'Dest length should be the same as the source length');
     $this->assertNotNull($getBlobResult->getMetadata(), 'blob Metadata');
     $expectedMetadata = count($options->getMetadata()) == 0 ? $metadata : $options->getMetadata();
     $resMetadata = $getBlobResult->getMetadata();
     $this->assertEquals(count($expectedMetadata), count($resMetadata), 'Metadata');
     foreach ($expectedMetadata as $key => $value) {
         $this->assertEquals($value, $resMetadata[strtolower($key)], 'Metadata(' . $key . ')');
     }
     // Make sure the last modified date is within 10 seconds
     $now = new \DateTime();
     $this->assertTrue(BlobServiceFunctionalTestData::diffInTotalSeconds($getBlobResult->getProperties()->getLastModified(), $now) < 10, 'Last modified date (' . $getBlobResult->getProperties()->getLastModified()->format(\DateTime::RFC1123) . ')' . ' should be within 10 seconds of $now (' . $now->format(\DateTime::RFC1123) . ')');
 }