function MediaSettingsTest::testSettingsForm

Same name in other branches
  1. 10 core/modules/media/tests/src/Functional/MediaSettingsTest.php \Drupal\Tests\media\Functional\MediaSettingsTest::testSettingsForm()

Tests that the media settings form stores a `null` iFrame domain.

File

core/modules/media/tests/src/Functional/MediaSettingsTest.php, line 50

Class

MediaSettingsTest
Testing the media settings.

Namespace

Drupal\Tests\media\Functional

Code

public function testSettingsForm() : void {
    $assert_session = $this->assertSession();
    $this->assertNull($this->config('media.settings')
        ->get('iframe_domain'));
    $this->drupalGet(Url::fromRoute('media.settings'));
    $assert_session->fieldExists('iframe_domain');
    // Explicitly submitting an empty string does not result in the
    // `iframe_domain` property getting set to the empty string: it is converted
    // to `null` to comply with the config schema.
    // @see \Drupal\media\Form\MediaSettingsForm::submitForm()
    $this->submitForm([
        'iframe_domain' => '',
    ], 'Save configuration');
    $assert_session->statusMessageContains('The configuration options have been saved.', 'status');
    $this->assertNull($this->config('media.settings')
        ->get('iframe_domain'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.