View source
<?php
namespace Drupal\Tests\inline_entity_form\Kernel\Migrate;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
class MigrateFieldInstanceWidgetSettingsTest extends MigrateTestBase {
public static $modules = [
'inline_entity_form',
'node',
'text',
];
protected function setUp() {
parent::setUp();
$this
->installConfig('node');
$this
->installEntitySchema('node');
$this
->executeMigrations([
'd7_node_type',
'd7_field',
'd7_field_instance',
'd7_field_instance_widget_settings',
]);
}
protected function assertEntity($id, $expected_entity_type, $expected_bundle) {
$entity = EntityFormDisplay::load($id);
$this
->assertInstanceOf(EntityFormDisplayInterface::class, $entity);
$this
->assertIdentical($expected_entity_type, $entity
->getTargetEntityTypeId());
$this
->assertIdentical($expected_bundle, $entity
->getTargetBundle());
}
protected function assertComponent($display_id, $component_id, $widget_type, $weight) {
$component = EntityFormDisplay::load($display_id)
->getComponent($component_id);
$this
->assertIsArray($component);
$this
->assertIdentical($widget_type, $component['type']);
$this
->assertIdentical($weight, $component['weight']);
}
public function testWidgetSettings() {
$this
->assertEntity('node.test.default', 'node', 'test');
$this
->assertComponent('node.test.default', 'body', 'text_textarea_with_summary', -4);
$this
->assertComponent('node.test.default', 'field_single', 'inline_entity_form_simple', -3);
$this
->assertComponent('node.test.default', 'field_multiple', 'inline_entity_form_complex', -2);
}
}