public function MediaMigrationPlainTest::testPlainFileToMediaMigration in Media Migration 8
Tests the migration of plain file and image fields to media reference.
@dataProvider providerTestPlainFileToMediaMigration
1 call to MediaMigrationPlainTest::testPlainFileToMediaMigration()
- MediaMigrationPlainTest::testChangeTracking in tests/
src/ Kernel/ Migrate/ MediaMigrationPlainTest.php - Tests media entity migration with change tracking enabled.
File
- tests/
src/ Kernel/ Migrate/ MediaMigrationPlainTest.php, line 20
Class
- MediaMigrationPlainTest
- Tests media migration from non-media source.
Namespace
Drupal\Tests\media_migration\Kernel\MigrateCode
public function testPlainFileToMediaMigration(bool $classic_node_migration, bool $preexisting_media_types) {
$this
->setClassicNodeMigration($classic_node_migration);
if ($preexisting_media_types) {
$this
->createStandardMediaTypes(TRUE);
}
$this
->assertArticleBodyFieldMigrationProcesses($classic_node_migration ? 'd7_node:article' : 'd7_node_complete:article', [
[
'plugin' => 'get',
'source' => 'body',
],
[
'plugin' => 'media_wysiwyg_filter',
],
[
'plugin' => 'ckeditor_link_file_to_linkit',
],
]);
$this
->executeMediaMigrations($classic_node_migration);
// 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();
$this
->assertFilterFormats();
}