function MediaLibraryAddFormTest::testDifferentAddForm

Same name in other branches
  1. 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryAddFormTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAddFormTest::testDifferentAddForm()
  2. 10 core/modules/media_library/tests/src/Kernel/MediaLibraryAddFormTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAddFormTest::testDifferentAddForm()
  3. 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryAddFormTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAddFormTest::testDifferentAddForm()

Tests overwriting of the add form.

File

core/modules/media_library/tests/src/Kernel/MediaLibraryAddFormTest.php, line 144

Class

MediaLibraryAddFormTest
Tests the media library add form.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function testDifferentAddForm() {
    $this->enableModules([
        'media_library_form_overwrite_test',
    ]);
    $entity_type_manager = \Drupal::entityTypeManager();
    $image = $entity_type_manager->getStorage('media_type')
        ->load('image');
    $image_source_definition = $image->getSource()
        ->getPluginDefinition();
    // Assert the overwritten form class is set to the media source.
    $this->assertSame(TestAddForm::class, $image_source_definition['forms']['media_library_add']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.