$expected_link_titles =
['Show Type Three media (selected)', 'Show Type One media', 'Show Type Two media', 'Show Type Four media'
];
$this->
assertSame($link_titles,
$expected_link_titles);
$this->
drupalGet('admin/structure/types/manage/basic_page/form-display'
);
// Ensure that the widget settings form is not displayed when only
// one media type is allowed.
$assert_session->
pageTextContains('Single media type'
);
$assert_session->
buttonNotExists('field_single_media_type_settings_edit'
);
$assert_session->
buttonExists('field_twin_media_settings_edit'
)->
press();
$this->
assertElementExistsAfterWait('css', '#field-twin-media .tabledrag-toggle-weight'
)->
press();
$assert_session->
fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_one][weight]'
)->
selectOption(0
);
$assert_session->
fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_three][weight]'
)->
selectOption(1
);
$assert_session->
fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_four][weight]'
)->
selectOption(2
);
$assert_session->
fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_two][weight]'
)->
selectOption(3
);
$assert_session->
buttonExists('Save'
)->
press();
$this->
drupalGet('node/add/basic_page'
);
$this->
openMediaLibraryForField('field_twin_media'
);
$link_titles =
array_map(function D
$link) { return $link->
getText();
},
$links);
$this->
assertSame($link_titles,
['Show Type One media (selected)', 'Show Type Three media', 'Show Type Four media', 'Show Type Two media'
]);