public function MediaMigrationTest::providerTestMediaMigration in Media Migration 8
Data provider for ::testMediaTokenToMediaEmbedTransform().
Return value
array The test cases.
File
- tests/
src/ Kernel/ Migrate/ MediaMigrationTest.php, line 141
Class
- MediaMigrationTest
- Tests media migration.
Namespace
Drupal\Tests\media_migration\Kernel\MigrateCode
public function providerTestMediaMigration() {
$default_attributes = [
'data-entity-type' => 'media',
'alt' => 'Different alternative text about blue.png in the test article',
'title' => 'Different title copy for blue.png in the test article',
'data-align' => 'center',
];
$test_cases = [
// ID reference method. This should be neutral for media_embed token
// transform destination.
'Entity embed destination, ID reference method, classic node migration, preexisting media types' => [
'Destination filter' => 'entity_embed',
'Reference method' => 'id',
'Classic node migration' => TRUE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-id' => '1',
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-id' => '7',
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.full',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Media embed destination, ID reference method, classic node migration, preexisting media types' => [
'Destination filter' => 'media_embed',
'Reference method' => 'id',
'Classic node migration' => TRUE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-view-mode' => 'wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-view-mode' => 'default',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Entity embed destination, ID reference method, complete node migration, preexisting media types' => [
'Destination filter' => 'entity_embed',
'Reference method' => 'id',
'Classic node migration' => FALSE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-id' => '1',
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.wysiwyg',
] + $default_attributes,
1 => [
'data-entity-id' => '7',
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.full',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Media embed destination, ID reference method, complete node migration, preexisting media types' => [
'Destination filter' => 'media_embed',
'Reference method' => 'id',
'Classic node migration' => FALSE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-view-mode' => 'wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-view-mode' => 'default',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
// UUID reference method.
'Entity embed destination, UUID reference method, classic node migration, preexisting media types' => [
'Destination filter' => 'entity_embed',
'Reference method' => 'uuid',
'Classic node migration' => TRUE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-entity-embed-display' => 'view_mode:media.full',
'data-embed-button' => 'media',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Media embed destination, UUID reference method, classic node migration, preexisting media types' => [
'Destination filter' => 'media_embed',
'Reference method' => 'uuid',
'Classic node migration' => TRUE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-view-mode' => 'wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-view-mode' => 'default',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Entity embed destination, UUID reference method, complete node migration, preexisting media types' => [
'Destination filter' => 'entity_embed',
'Reference method' => 'uuid',
'Classic node migration' => FALSE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-embed-button' => 'media',
'data-entity-embed-display' => 'view_mode:media.wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-entity-embed-display' => 'view_mode:media.full',
'data-embed-button' => 'media',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
'Media embed destination, UUID reference method, complete node migration, preexisting media types' => [
'Destination filter' => 'media_embed',
'Reference method' => 'uuid',
'Classic node migration' => FALSE,
'expected_node1_embed_html_attributes' => [
0 => [
'data-entity-uuid' => TRUE,
'data-view-mode' => 'wysiwyg',
] + $default_attributes,
1 => [
'data-entity-type' => 'media',
'data-entity-uuid' => TRUE,
'data-view-mode' => 'default',
'alt' => 'A yellow image',
'title' => 'This is a yellow image',
],
],
'Preexisting media types' => TRUE,
],
];
// Add 'no initial media types' test cases.
$test_cases_without_media_types = [];
foreach ($test_cases as $test_case_label => $test_case) {
$without_media_label = preg_replace('/preexisting media types$/', 'no media types', $test_case_label);
$test_case['Preexisting media types'] = FALSE;
$test_cases_without_media_types[$without_media_label] = $test_case;
}
$test_cases += $test_cases_without_media_types;
// Drupal 8.8.x only has 'classic' node migrations.
// @see https://www.drupal.org/node/3105503
if (version_compare(\Drupal::VERSION, '8.9', '<')) {
$test_cases = array_filter($test_cases, function ($test_case) {
return $test_case['Classic node migration'];
});
}
return $test_cases;
}