Unverified Commit 1a8b7f16 authored by alexpott's avatar alexpott

Issue #2928851 by chr.fritsch, daniel.bosen, yogeshmpawar, jefuri, dagomar,...

Issue #2928851 by chr.fritsch, daniel.bosen, yogeshmpawar, jefuri, dagomar, seanB, marcoscano, phenaproxima, alexpott, borisson_: Allow the media source of a media type to be changed when creating a new media type
parent 3c5bf74b
......@@ -118,7 +118,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#attributes' => ['id' => 'source-dependent'],
];
if ($source) {
if (!$this->entity->isNew()) {
$source_description = $this->t('<em>The media source cannot be changed after the media type is created.</em>');
}
else {
......@@ -134,7 +134,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#required' => TRUE,
// Once the media type is created, its source plugin cannot be changed
// anymore.
'#disabled' => !empty($source),
'#disabled' => !$this->entity->isNew(),
];
if ($source) {
......
......@@ -11,6 +11,45 @@
*/
class MediaTypeCreationTest extends MediaJavascriptTestBase {
/**
* Tests the source field behavior on the add media type form.
*/
public function testSourceChangeOnMediaTypeCreationForm() {
$session = $this->getSession();
$page = $session->getPage();
$assert_session = $this->assertSession();
$label = 'Type with Default Field';
$mediaTypeMachineName = str_replace(' ', '_', strtolower($label));
$this->drupalGet('admin/structure/media/add');
// Fill in a label to the media type.
$page->fillField('label', $label);
$this->assertNotEmpty(
$assert_session->waitForElementVisible('css', '.machine-name-value')
);
// Select the media source used by our media type.
$assert_session->selectExists('Media source')->selectOption('test_different_displays');
$this->assertNotEmpty(
$assert_session->waitForElementVisible('css', 'fieldset[data-drupal-selector="edit-source-configuration"]')
);
// Change the media source.
$assert_session->selectExists('Media source')->selectOption('test');
$this->assertNotEmpty(
$assert_session->waitForElement('css', 'fieldset[data-drupal-selector="edit-source-configuration"] .fieldset-wrapper .placeholder:contains("Text (plain)")')
);
$page->pressButton('Save');
// Check that source can not be changed anymore.
$this->drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}");
$assert_session->pageTextContains('The media source cannot be changed after the media type is created');
$assert_session->fieldDisabled('Media source');
}
/**
* Tests the media type creation form.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment