You are here

public function S3fsConfigFormTest::testS3fsConfigurationForm in S3 File System 4.0.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/S3fsConfigFormTest.php \Drupal\Tests\s3fs\Functional\S3fsConfigFormTest::testS3fsConfigurationForm()

Test the S3fs config form.

File

tests/src/Functional/S3fsConfigFormTest.php, line 48

Class

S3fsConfigFormTest
Tests s3fs configuration form.

Namespace

Drupal\Tests\s3fs\Functional

Code

public function testS3fsConfigurationForm() {
  $bucketRegion = $this
    ->config('s3fs.settings')
    ->get('region');

  // Set the region incorrectly so we can verify it changes before
  // it reaches the getAmazonS3Client() call.
  if ($bucketRegion == 'us-east-1') {
    $this
      ->config('s3fs.settings')
      ->set('region', 'us-east-2')
      ->save();
  }
  else {
    $this
      ->config('s3fs.settings')
      ->set('region', 'us-east-1')
      ->save();
  }
  $edit['credentials_file'] = '/tmp/test.ini';
  $edit['use_credentials_cache'] = 1;
  $edit['credentials_cache_dir'] = '/tmp/testcache';
  $edit['bucket'] = 's3fs-testing-bucket';
  $edit['use_cname'] = 1;
  $edit['domain_root'] = 'none';
  $edit['domain'] = 'domaincheck.com';
  $edit['use_path_style_endpoint'] = 1;
  $edit['encryption'] = 'AES256';
  $edit['use_https'] = 1;
  $edit['read_only'] = 1;
  $edit['disable_cert_verify'] = 0;
  $edit['disable_shared_config_files'] = 1;
  $edit['root_folder'] = 'rootfoldercheck';
  $edit['presigned_urls'] = '60|private_files/*';
  $edit['saveas'] = 'video/*';
  $edit['torrents'] = 'big_files/*';
  $this
    ->drupalPostForm('admin/config/media/s3fs', $edit, t('Save configuration'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $currentRegion = $this
    ->config('s3fs.settings')
    ->get('region');
  $this
    ->assertEquals($bucketRegion, $currentRegion, 'Region Detection Successful');
}