public function MigrateMediaFromNonMediaSourceTest::testPlainFileToMediaMigration in Media Migration 8
Tests the result of the media migration.
@dataProvider providerTestPlainFileToMediaMigration
File
- tests/
src/ Functional/ MigrateMediaFromNonMediaSourceTest.php, line 44
Class
- MigrateMediaFromNonMediaSourceTest
- Tests migration from a source without enabled media module to media.
Namespace
Drupal\Tests\media_migration\FunctionalCode
public function testPlainFileToMediaMigration(bool $classic_node_migration, bool $preexisting_media_types) {
$this
->setClassicNodeMigration($classic_node_migration);
// Delete preexisting media types.
$media_types = $this->container
->get('entity_type.manager')
->getStorage('media_type')
->loadMultiple();
foreach ($media_types as $media_type) {
$media_type
->delete();
}
if ($preexisting_media_types) {
$this
->createStandardMediaTypes(TRUE);
}
$this
->assertMigrateUpgradeViaUi(FALSE);
$this
->assertMediaMigrationResults();
// Check configurations.
$this
->assertMediaFieldsAllowedTypes('node', 'article', 'field_image', [
'image',
]);
$this
->assertMediaFieldsAllowedTypes('node', 'article', 'field_image_multi', [
'image',
]);
// File fields must allow referencing any kind of existing media.
$media_type_ids = array_keys($this->container
->get('entity_type.manager')
->getStorage('media_type')
->loadMultiple());
$this
->assertMediaFieldsAllowedTypes('node', 'article', 'field_file', $media_type_ids);
$this
->assertMediaFieldsAllowedTypes('node', 'article', 'field_file_multi', $media_type_ids);
// Check media source field config entities.
$this
->assertNonMediaToMediaImageMediaBundleSourceFieldProperties();
$this
->assertNonMediaToMediaDocumentMediaBundleSourceFieldProperties();
$this
->assertNonMediaToMediaAudioMediaBundleSourceFieldProperties();
$this
->assertNonMediaToMediaVideoMediaBundleSourceFieldProperties();
// Check media entities.
$this
->assertNonMediaToMedia1FieldValues();
$this
->assertNonMediaToMedia2FieldValues();
$this
->assertNonMediaToMedia3FieldValues();
$this
->assertNonMediaToMedia6FieldValues();
$this
->assertNonMediaToMedia7FieldValues();
$this
->assertNonMediaToMedia8FieldValues();
$this
->assertNonMediaToMedia9FieldValues();
$this
->assertNonMediaToMedia10FieldValues();
$this
->assertNonMediaToMedia11FieldValues();
$this
->assertNonMediaToMedia12FieldValues();
// Check nodes.
$this
->assertNonMediaToMediaNode1FieldValues();
$this
->assertNonMediaToMediaNode2FieldValues();
}