You are here

public function SettingsFormTest::testOriginTrailingslashIsRemoved in Stage File Proxy 8

Tests if the origin URL gets correctly trimmed.

File

tests/src/Functional/SettingsFormTest.php, line 41

Class

SettingsFormTest
Tests the settings form validation.

Namespace

Drupal\Tests\stage_file_proxy\Functional

Code

public function testOriginTrailingslashIsRemoved() {
  $settings_path = Url::fromRoute('stage_file_proxy.admin_form');
  $this
    ->drupalLogin($this->adminUser);
  $testOrigin = 'http://example.com';
  $edit = [
    // Test with adding a slash.
    'origin' => $testOrigin . '/',
  ];
  $this
    ->drupalPostForm($settings_path, $edit, 'Save configuration');

  // Test if the form was saved without error.
  $this
    ->assertText('Your settings have been saved.');

  // Test if the stored value has the trailing slash removed.
  $newOrigin = $this
    ->config('stage_file_proxy.settings')
    ->get('origin');
  $this
    ->assertIdentical($newOrigin, $testOrigin);
}