You are here

public function StreamWrapperTest::testSaveAs in AmazonS3 7.2

@covers \Drupal\amazons3\StreamWrapper::getExternalUrl @covers \Drupal\amazons3\StreamWrapper::getS3Url @covers \Drupal\amazons3\StreamWrapper::getContentDispositionAttachment @covers \Drupal\amazons3\StreamWrapper::forceDownload

File

tests/StreamWrapperTest.php, line 376

Class

StreamWrapperTest
Tests \Drupal\amazons3\StreamWrapper.

Namespace

Drupal\amazons3Test

Code

public function testSaveAs() {
  $config = StreamWrapperConfiguration::fromConfig([
    'bucket' => 'bucket.example.com',
    'region' => 'region',
    'caching' => FALSE,
    'expiration' => 0,
    'saveAsPaths' => new MatchablePaths(BasicPath::factory(array(
      'force-download/.*',
    ))),
  ]);
  $wrapper = new StreamWrapper($config);
  $wrapper
    ->setUri('s3://bucket.example.com/force-download/test.jpg');
  $this
    ->assertRegExp('!.*response-content-disposition=attachment%3B%20filename%3D%22test\\.jpg.*!', $wrapper
    ->getExternalUrl());
}