You are here

protected function S3ClientTest::mockClient in AmazonS3 7.2

Generate a mock client ready to mock HTTP requests.

Return value

\Aws\S3\S3Client

2 calls to S3ClientTest::mockClient()
S3ClientTest::testGetBucketLocation in tests/S3ClientTest.php
@covers \Drupal\amazons3\S3Client::getBucketLocation
S3ClientTest::testValidateBucketExists in tests/S3ClientTest.php
@covers \Drupal\amazons3\S3Client::validateBucketExists

File

tests/S3ClientTest.php, line 104

Class

S3ClientTest
Tests \Drupal\amazons3\S3Client.

Namespace

Drupal\amazons3

Code

protected function mockClient() {

  // Instantiate the AWS service builder.
  $config = array(
    'includes' => array(
      0 => '_aws',
    ),
    'services' => array(
      'default_settings' => array(
        'params' => array(
          'region' => 'us-east-1',
        ),
      ),
      'cloudfront' => array(
        'extends' => 'cloudfront',
        'params' => array(
          'private_key' => 'change_me',
          'key_pair_id' => 'change_me',
        ),
      ),
    ),
    'credentials' => array(
      'key' => 'placeholder',
      'secret' => 'placeholder',
    ),
  );
  $aws = \Aws\Common\Aws::factory($config);

  // Configure the tests to use the instantiated AWS service builder
  \Guzzle\Tests\GuzzleTestCase::setServiceBuilder($aws);
  $client = $this
    ->getServiceBuilder()
    ->get('s3', TRUE);
  return $client;
}