class MediaCreationTest extends MediaKernelTestBase
{ /**
* Tests creating a media type programmatically.
*/
public function testMediaTypeCreation() { $media_type_storage =
$this->container->
get('entity_type.manager'
)->
getStorage('media_type'
);
$this->
assertInstanceOf(MediaTypeInterface::
class, MediaType::
load($this->testMediaType->
id()));
// Test a media type created from default configuration.
$this->container->
get('module_installer'
)->
install(['media_test_type'
]);
$test_media_type =
$media_type_storage->
load('test'
);
$this->
assertInstanceOf(MediaTypeInterface::
class,
$test_media_type);
$this->
assertSame('Test type',
$test_media_type->
get('label'
), 'Could not assure the correct type name.'
);
$this->
assertSame('Test type.',
$test_media_type->
get('description'
), 'Could not assure the correct type description.'
);
$this->
assertSame('test',
$test_media_type->
get('source'
), 'Could not assure the correct media source.'
);
// Source field is not set on the media source, but it should never
// be created automatically when a config is being imported.
$this->
assertSame(['source_field' => '', 'test_config_value' => 'Kakec'
],
$test_media_type->
get('source_configuration'
), 'Could not assure the correct media source configuration.'
);