You are here

public function S3Test::testMergeConfiguration in Flysystem - S3 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/Flysystem/S3Test.php \NoDrupal\Tests\flysystem_s3\Unit\Flysystem\S3Test::testMergeConfiguration()

Tests merging defaults into configuration arrays.

File

tests/src/Unit/Flysystem/S3Test.php, line 54

Class

S3Test
@coversDefaultClass \Drupal\flysystem_s3\Flysystem\S3 @covers \Drupal\flysystem_s3\Flysystem\S3 @group flysystem_s3

Namespace

NoDrupal\Tests\flysystem_s3\Unit\Flysystem

Code

public function testMergeConfiguration() {
  $container = new ContainerBuilder();
  $container
    ->set('request_stack', new RequestStack());
  $container
    ->get('request_stack')
    ->push(Request::create('https://example.com/'));
  $configuration = [
    'key' => 'fee',
    'secret' => 'fo',
    'region' => 'eu-west-1',
    'bucket' => 'example-bucket',
  ];
  $configuration = S3::mergeConfiguration($container, $configuration);
  $this
    ->assertSame('https', $configuration['protocol']);
  $client_config = S3::mergeClientConfiguration($container, $configuration);
  $this
    ->assertSame('eu-west-1', $client_config['region']);
  $this
    ->assertNull($client_config['endpoint']);
  $this
    ->assertInstanceOf(Credentials::class, $client_config['credentials']);
}