public function StreamWrapperConfigurationTest::testFromDrupalVariables in AmazonS3 7.2
@covers Drupal\amazons3\StreamWrapperConfiguration::fromDrupalVariables @covers Drupal\amazons3\StreamWrapperConfiguration::getS3Domain
File
- tests/
StreamWrapperConfigurationTest.php, line 135
Class
- StreamWrapperConfigurationTest
- @class StreamWrapperConfigurationTest @package Drupal\amazons3Test
Namespace
Drupal\amazons3TestCode
public function testFromDrupalVariables() {
StreamWrapperConfiguration::setVariableData([
'amazons3_bucket' => 'default.example.com',
'amazons3_region' => 'region',
'amazons3_hostname' => 'api.example.com',
'amazons3_cname' => TRUE,
'amazons3_domain' => 'static.example.com',
'amazons3_domain_scheme' => 'http',
'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
->getDomainScheme(), 'http');
$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_region' => 'region',
'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',
'amazons3_region' => 'region',
]);
$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',
'amazons3_region' => 'region',
]);
$config = StreamWrapperConfiguration::fromDrupalVariables();
$this
->assertEquals('bucket.s3.amazonaws.com', $config
->getDomain());
StreamWrapperConfiguration::setVariableData(array());
}