You are here

protected function ThunderAwsTestFixtureTrait::getTestFixture in Thunder 6.2.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()
  2. 8.2 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()
  3. 8.3 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()
  4. 8.4 tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()
  5. 6.0.x tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()
  6. 6.1.x tests/src/Traits/ThunderAwsTestFixtureTrait.php \Drupal\Tests\thunder\Traits\ThunderAwsTestFixtureTrait::getTestFixture()

Gets a test fixture from AWS.

Parameters

string $filename: The test fixture filename.

Return value

string The local path to the test fixture.

1 call to ThunderAwsTestFixtureTrait::getTestFixture()
Thunder2UpdateTest::setDatabaseDumpFiles in tests/src/Functional/Thunder2UpdateTest.php
Set database dump files to be used.

File

tests/src/Traits/ThunderAwsTestFixtureTrait.php, line 28

Class

ThunderAwsTestFixtureTrait
Trait to download test fixtures from AWS.

Namespace

Drupal\Tests\thunder\Traits

Code

protected function getTestFixture($filename) {

  // Statically cache to prevent unnecessary requests.
  static $files = [];
  if (!isset($files[$filename])) {
    $local_dir = sys_get_temp_dir() . '/thunder_test_fixtures';
    @mkdir($local_dir);
    $local = $local_dir . '/' . $filename;
    $remote = 'https://s3-eu-west-1.amazonaws.com/thunder-public-files/test_fixtures/' . $filename;
    $client = $this
      ->getHttpClient();
    if (!file_exists($local) || sha1_file($local) !== $client
      ->head($remote)
      ->getHeaderLine('x-amz-meta-sha')) {
      $client
        ->get($remote, [
        'sink' => $local,
      ]);
    }
    $files[$filename] = $local;
  }
  return $files[$filename];
}