public function Update400Test::testRequireDocumentMediaSourceField in Lightning Media 8.4
Tests making the Document media type's source field required.
@covers ::requireDocumentMediaSourceField
File
- modules/
lightning_media_document/ tests/ src/ Kernel/ Update400Test.php, line 39
Class
- Update400Test
- Tests configuration updates targeting Lightning Media Document 4.0.0.
Namespace
Drupal\Tests\lightning_media_document\KernelCode
public function testRequireDocumentMediaSourceField() {
$this
->createMediaType('file', [
'id' => 'document',
'label' => 'Document',
]);
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_document',
'type' => 'string',
'entity_type' => 'media',
]);
$field_storage
->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'document',
'label' => 'Document',
]);
$field
->save();
$this
->assertFalse($field
->isRequired());
$io = $this
->prophesize(StyleInterface::class);
$io
->confirm('Do you want to make the Document field required on the Document media type?')
->willReturn(TRUE)
->shouldBeCalled();
Update400::create($this->container)
->requireDocumentMediaSourceField($io
->reveal());
$field = FieldConfig::loadByName('media', 'document', 'field_document');
$this
->assertTrue($field
->isRequired());
}