You are here

public function StreamWrapperTest::setUp in AmazonS3 7.2

File

tests/StreamWrapperTest.php, line 33

Class

StreamWrapperTest
Tests \Drupal\amazons3\StreamWrapper.

Namespace

Drupal\amazons3Test

Code

public function setUp() {
  StreamWrapper::setS3ClientClass('Drupal\\amazons3Test\\Stub\\S3Client');
  $config = StreamWrapperConfiguration::fromConfig([
    'bucket' => 'bucket.example.com',
    'region' => 'region',
    'caching' => FALSE,
    'expiration' => 0,
  ]);
  StreamWrapper::setDefaultConfig($config);
  StreamWrapper::setClient(S3Client::factory([
    'credentials' => new Credentials('placeholder', 'placeholder'),
  ]));
  $this->wrapper = new StreamWrapper($config);
  if (in_array('s3', stream_get_wrappers())) {
    stream_wrapper_unregister('s3');
  }
  stream_wrapper_register('s3', '\\Drupal\\amazons3\\StreamWrapper', STREAM_IS_URL);
}