You are here

public function S3ClientTest::testFactory in AmazonS3 7.2

@covers Drupal\amazons3\S3Client::factory

File

tests/S3ClientTest.php, line 20

Class

S3ClientTest
Tests \Drupal\amazons3\S3Client.

Namespace

Drupal\amazons3

Code

public function testFactory() {
  DrupalS3Client::setVariableData([
    'amazons3_key' => 'key',
    'amazons3_secret' => 'secret',
    'amazons3_hostname' => 'hostname',
    'amazons3_region' => 'region',
  ]);
  DrupalS3Client::resetCalled();
  $client = DrupalS3Client::factory(array(), 'fake-bucket');
  $this
    ->assertInstanceOf('Aws\\S3\\S3Client', $client);
  $this
    ->assertEquals('key', $client
    ->getCredentials()
    ->getAccessKeyId());
  $this
    ->assertEquals('secret', $client
    ->getCredentials()
    ->getSecretKey());
  $this
    ->assertEquals('hostname', $client
    ->getBaseUrl());
  $this
    ->assertEquals('region', $client
    ->getRegion());
  DrupalS3Client::setVariableData(array());
}