$this->
assertSame('media_test',
$type->
getSource()->
createSourceField($type)->
getName());
} /**
* Tests configuration form submit handler on the base media source plugin.
*/
public function testSourceConfigurationSubmit() { /** @var \Drupal\media\MediaSourceManager $manager */
$manager =
$this->container->
get('plugin.manager.media.source'
);
$form =
[];
$form_state =
new FormState();
$form_state->
setValues(['test_config_value' => 'Somewhere over the rainbow.'
]);
/** @var \Drupal\media\MediaSourceInterface $source */
$source =
$manager->
createInstance('test',
[]);
$source->
submitConfigurationForm($form,
$form_state);
$expected =
['source_field' => 'field_media_test_1', 'test_config_value' => 'Somewhere over the rainbow.'
];
$this->
assertSame($expected,
$source->
getConfiguration(), 'Submitted values were saved correctly.'
);
// Try to save a NULL value.
$form_state->
setValue('test_config_value', NULL
);
$source->
submitConfigurationForm($form,
$form_state);
$expected['test_config_value'
] = NULL;