function MediaSourceFileTest::testSourceFieldSettingsEditing
Same name in other branches
- 9 core/modules/media/tests/src/Functional/MediaSourceFileTest.php \Drupal\Tests\media\Functional\MediaSourceFileTest::testSourceFieldSettingsEditing()
- 10 core/modules/media/tests/src/Functional/MediaSourceFileTest.php \Drupal\Tests\media\Functional\MediaSourceFileTest::testSourceFieldSettingsEditing()
- 11.x core/modules/media/tests/src/Functional/MediaSourceFileTest.php \Drupal\Tests\media\Functional\MediaSourceFileTest::testSourceFieldSettingsEditing()
Test that it's possible to change the allowed file extensions.
File
-
core/
modules/ media/ tests/ src/ Functional/ MediaSourceFileTest.php, line 22
Class
- MediaSourceFileTest
- Tests the file media source.
Namespace
Drupal\Tests\media\FunctionalCode
public function testSourceFieldSettingsEditing() {
$session = $this->getSession();
$page = $session->getPage();
$assert_session = $this->assertSession();
$media_type = $this->createMediaType('file');
$media_type_id = $media_type->id();
$this->assertSame('txt doc docx pdf', FieldConfig::load("media.{$media_type_id}.field_media_file")->get('settings')['file_extensions']);
$this->drupalGet("admin/structure/media/manage/{$media_type_id}/fields/media.{$media_type_id}.field_media_file");
// File extension field exists.
$assert_session->fieldExists('Allowed file extensions');
// Add another extension.
$page->fillField('settings[file_extensions]', 'txt, doc, docx, pdf, odt');
$page->pressButton('Save settings');
$this->drupalGet("admin/structure/media/manage/{$media_type_id}/fields/media.{$media_type_id}.field_media_file");
// Verify that new extension is present.
$assert_session->fieldValueEquals('settings[file_extensions]', 'txt, doc, docx, pdf, odt');
$this->assertSame('txt doc docx pdf odt', FieldConfig::load("media.{$media_type_id}.field_media_file")->get('settings')['file_extensions']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.