You are here

public function StreamWrapperConfigurationTest::testSetters in AmazonS3 7.2

@covers Drupal\amazons3\StreamWrapperConfiguration

File

tests/StreamWrapperConfigurationTest.php, line 45

Class

StreamWrapperConfigurationTest
@class StreamWrapperConfigurationTest @package Drupal\amazons3Test

Namespace

Drupal\amazons3Test

Code

public function testSetters() {
  $config = StreamWrapperConfiguration::fromConfig(array(
    'bucket' => 'bucket',
    'region' => 'region',
  ));
  $config
    ->setBucket('different-bucket');
  $this
    ->assertEquals('different-bucket', $config
    ->getBucket());
  $config
    ->setRegion('different-region');
  $this
    ->assertEquals('different-region', $config
    ->getRegion());
  $config
    ->enableCaching();
  $this
    ->assertTrue($config
    ->isCaching());
  $config
    ->setCacheLifetime(666);
  $this
    ->assertEquals(666, $config
    ->getCacheLifetime());
  $config
    ->disableCaching();
  $this
    ->assertFalse($config
    ->isCaching());
  $config
    ->setDomain('cdn.example.com');
  $this
    ->assertEquals('cdn.example.com', $config
    ->getDomain());
  $this
    ->assertEquals('https', $config
    ->getDomainScheme());
  $config
    ->setDomainScheme('http');
  $this
    ->assertEquals('http', $config
    ->getDomainScheme());
  $config
    ->setHostname('api.example.com');
  $this
    ->assertEquals('api.example.com', $config
    ->getHostname());
  $config
    ->serveWithCloudFront();
  $this
    ->assertTrue($config
    ->isCloudFront());
  $config
    ->serveWithS3();
  $this
    ->assertFalse($config
    ->isCloudFront());
  $mp = new MatchablePaths(array(
    '/',
  ));
  $config
    ->setPresignedPaths($mp);
  $this
    ->assertEquals($mp, $config
    ->getPresignedPaths());
  $config
    ->setReducedRedundancyPaths($mp);
  $this
    ->assertEquals($mp, $config
    ->getReducedRedundancyPaths());
  $config
    ->setSaveAsPaths($mp);
  $this
    ->assertEquals($mp, $config
    ->getSaveAsPaths());
  $config
    ->setTorrentPaths($mp);
  $this
    ->assertEquals($mp, $config
    ->getTorrentPaths());
  $config
    ->serveWithCloudFront();
  $config
    ->setCloudFrontCredentials('/dev/null', 'keypair-id');
  $this
    ->assertInstanceOf('Aws\\CloudFront\\CloudFrontClient', $config
    ->getCloudFront());
}