diff --git a/core/modules/media/tests/src/Kernel/MediaSourceTest.php b/core/modules/media/tests/src/Kernel/MediaSourceTest.php index f59524fd82..0f07ab2646 100644 --- a/core/modules/media/tests/src/Kernel/MediaSourceTest.php +++ b/core/modules/media/tests/src/Kernel/MediaSourceTest.php @@ -431,10 +431,23 @@ public function testSourceConfigurationSubmit() { /** @var \Drupal\media\MediaSourceInterface $source */ $source = $manager->createInstance('test', []); $source->submitConfigurationForm($form, $form_state); - $expected = ['test_config_value' => 'Somewhere over the rainbow.', 'source_field' => 'field_media_test_1']; $this->assertEquals($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; + $this->assertEquals($expected, $source->getConfiguration(), 'Submitted values were saved correctly.'); + + // Make sure that the config keys are determined correctly even if the + // existing value is NULL. + $form_state->setValue('test_config_value', 'Somewhere over the rainbow.'); + $source->submitConfigurationForm($form, $form_state); + $expected['test_config_value'] = 'Somewhere over the rainbow.'; + $this->assertEquals($expected, $source->getConfiguration(), 'Submitted values were saved correctly.'); + + // Make sure that a non-relevant value will be skipped. $form_state->setValue('not_relevant', 'Should not be saved in the plugin.'); $source->submitConfigurationForm($form, $form_state); $this->assertEquals($expected, $source->getConfiguration(), 'Submitted values were saved correctly.');