public function MediaTypeTest::testCloneMediaInLibraryField in Lightning Media 8
Same name and namespace in other branches
- 8.4 tests/src/Kernel/MediaTypeTest.php \Drupal\Tests\lightning_media\Kernel\MediaTypeTest::testCloneMediaInLibraryField()
- 8.2 tests/src/Kernel/MediaTypeTest.php \Drupal\Tests\lightning_media\Kernel\MediaTypeTest::testCloneMediaInLibraryField()
- 8.3 tests/src/Kernel/MediaTypeTest.php \Drupal\Tests\lightning_media\Kernel\MediaTypeTest::testCloneMediaInLibraryField()
Tests that field_media_in_library is auto-cloned for new media bundles.
File
- tests/
src/ Kernel/ MediaTypeTest.php, line 46
Class
- MediaTypeTest
- Tests of API-level Lightning functionality related to media types.
Namespace
Drupal\Tests\lightning_media\KernelCode
public function testCloneMediaInLibraryField() {
$type = $this
->createMediaType([], 'file')
->id();
/** @var \Drupal\media\MediaInterface $media */
$media = $this->container
->get('entity_type.manager')
->getStorage('media')
->create([
'bundle' => $type,
]);
$this
->assertTrue($media
->hasField('field_media_in_library'));
// The field should be present in the form as a checkbox.
$component = entity_get_form_display('media', $type, 'default')
->getComponent('field_media_in_library');
$this
->assertInternalType('array', $component);
}