/**
  * @covers Drupal\amazons3\StreamWrapperConfiguration::fromDrupalVariables
  * @covers Drupal\amazons3\StreamWrapperConfiguration::getS3Domain
  */
 public function testFromDrupalVariables()
 {
     StreamWrapperConfiguration::setVariableData(['amazons3_bucket' => 'default.example.com', 'amazons3_hostname' => 'api.example.com', 'amazons3_cname' => TRUE, 'amazons3_domain' => 'static.example.com', 'amazons3_cloudfront' => TRUE, 'amazons3_cloudfront_private_key' => '/dev/null', 'amazons3_cloudfront_keypair_id' => 'example', 'amazons3_cache' => TRUE, 'amazons3_torrents' => array('.*'), 'amazons3_presigned_urls' => array(array('pattern' => '.*', 'timeout' => '60')), 'amazons3_saveas' => array('.*'), 'amazons3_rrs' => array('.*')]);
     $config = StreamWrapperConfiguration::fromDrupalVariables();
     $this->assertEquals($config->getBucket(), 'default.example.com');
     $this->assertEquals($config->getHostname(), 'api.example.com');
     $this->assertEquals($config->getDomain(), 'static.example.com');
     $this->assertEquals($config->isCloudFront(), TRUE);
     $this->assertInstanceOf('Aws\\CloudFront\\CloudFrontClient', $config->getCloudFront());
     $this->assertEquals($config->isCaching(), TRUE);
     $this->assertInstanceOf('Drupal\\amazons3\\Matchable\\MatchablePaths', $config->getTorrentPaths());
     $this->assertInstanceOf('Drupal\\amazons3\\Matchable\\MatchablePaths', $config->getPresignedPaths());
     $this->assertInstanceOf('Drupal\\amazons3\\Matchable\\MatchablePaths', $config->getSaveAsPaths());
     $this->assertInstanceOf('Drupal\\amazons3\\Matchable\\MatchablePaths', $config->getReducedRedundancyPaths());
     StreamWrapperConfiguration::setVariableData(['amazons3_bucket' => 'default.example.com', 'amazons3_cname' => TRUE, 'amazons3_cache' => FALSE]);
     $config = StreamWrapperConfiguration::fromDrupalVariables();
     $this->assertEquals($config->getBucket(), $config->getDomain());
     $this->assertFalse($config->isCaching());
     // When the bucket has a dot, check that the bucket is not in the domain.
     StreamWrapperConfiguration::setVariableData(['amazons3_bucket' => 'default.example.com']);
     $config = StreamWrapperConfiguration::fromDrupalVariables();
     $this->assertEquals('s3.amazonaws.com', $config->getDomain());
     // When the bucket does not have a dot, check the bucket is in the
     // subdomain.
     StreamWrapperConfiguration::setVariableData(['amazons3_bucket' => 'bucket']);
     $config = StreamWrapperConfiguration::fromDrupalVariables();
     $this->assertEquals('bucket.s3.amazonaws.com', $config->getDomain());
     StreamWrapperConfiguration::setVariableData(array());
 }