public function ParagraphsFieldMigrationTest::testParagrahsFieldInstanceMigration in Paragraphs 8
Test if the paragraph field instances were migrated.
File
- tests/
src/ Kernel/ migrate/ ParagraphsFieldMigrationTest.php, line 58
Class
- ParagraphsFieldMigrationTest
- Test the migration of paragraphs and field collection fields.
Namespace
Drupal\Tests\paragraphs\Kernel\migrateCode
public function testParagrahsFieldInstanceMigration() {
$this
->executeMigrationWithDependencies('d7_field_instance');
$total_bundles = count(ParagraphsType::loadMultiple());
$this
->assertFieldInstanceExists('node', 'paragraphs_test', 'field_field_collection_test');
$field = FieldConfig::loadByName('node', 'paragraphs_test', 'field_field_collection_test');
$handler_settings = $field
->getSetting('handler_settings');
$this
->assertEquals(0, $handler_settings['negate']);
$this
->assertCount(1, $handler_settings['target_bundles']);
$this
->assertEquals('field_collection_test', $handler_settings['target_bundles']['field_collection_test']);
$this
->assertCount($total_bundles, $handler_settings['target_bundles_drag_drop']);
$this
->assertFieldInstanceExists('node', 'paragraphs_test', 'field_any_paragraph');
$field = FieldConfig::loadByName('node', 'paragraphs_test', 'field_any_paragraph');
$handler_settings = $field
->getSetting('handler_settings');
$this
->assertEquals(0, $handler_settings['negate']);
$this
->assertEmpty($handler_settings['target_bundles']);
$this
->assertCount($total_bundles, $handler_settings['target_bundles_drag_drop']);
$this
->assertFieldInstanceExists('node', 'paragraphs_test', 'field_paragraph_one_only');
$field = FieldConfig::loadByName('node', 'paragraphs_test', 'field_paragraph_one_only');
$handler_settings = $field
->getSetting('handler_settings');
$this
->assertEquals(0, $handler_settings['negate']);
$this
->assertCount(1, $handler_settings['target_bundles']);
$this
->assertEquals('paragraph_bundle_one', $handler_settings['target_bundles']['paragraph_bundle_one']);
$this
->assertCount($total_bundles, $handler_settings['target_bundles_drag_drop']);
$this
->assertFieldInstanceExists('paragraph', 'paragraph_bundle_one', 'field_text', 'string');
$this
->assertFieldInstanceExists('paragraph', 'paragraph_bundle_one', 'field_text_list', 'list_string');
$this
->assertFieldInstanceExists('paragraph', 'paragraph_bundle_two', 'field_text', 'string');
$this
->assertFieldInstanceExists('paragraph', 'paragraph_bundle_two', 'field_email', 'email');
$this
->assertFieldInstanceExists('paragraph', 'field_collection_test', 'field_text', 'string');
$this
->assertFieldInstanceExists('paragraph', 'field_collection_test', 'field_integer_list', 'list_integer');
}