function MediaLibraryAddFormTest::testSelectedTypeValidation
Tests the validation of the selected type in the media library add form.
File
-
core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAddFormTest.php, line 132
Class
- MediaLibraryAddFormTest
- Tests the media library add form.
Namespace
Drupal\Tests\media_library\KernelCode
public function testSelectedTypeValidation() {
$state = MediaLibraryState::create('test', [
'image',
'remote_video',
'header_image',
], 'header_image', -1);
$form_state = new FormState();
$form_state->set('media_library_state', $state);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage("The 'header_image' media type does not exist.");
\Drupal::formBuilder()->buildForm(FileUploadForm::class, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.