You are here

protected function FieldInstanceTest::assertEntity in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/commerce/tests/src/Kernel/Migrate/commerce1/FieldInstanceTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\FieldInstanceTest::assertEntity()
  2. 3.0.x modules/commerce/tests/src/Kernel/Migrate/commerce1/FieldInstanceTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\FieldInstanceTest::assertEntity()

Asserts various aspects of a field config entity.

Parameters

string $id: The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.

string $expected_label: The expected field label.

string $expected_field_type: The expected field type.

bool $is_required: Whether or not the field is required.

bool $expected_translatable: Whether or not the field is expected to be translatable.

1 call to FieldInstanceTest::assertEntity()
FieldInstanceTest::testFieldInstances in modules/commerce/tests/src/Kernel/Migrate/commerce1/FieldInstanceTest.php
Tests migrating D7 field instances to field_config entities.

File

modules/commerce/tests/src/Kernel/Migrate/commerce1/FieldInstanceTest.php, line 67

Class

FieldInstanceTest
Tests field instance migration.

Namespace

Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1

Code

protected function assertEntity($id, $expected_label, $expected_field_type, $is_required, $expected_translatable) {
  list($expected_entity_type, $expected_bundle, $expected_name) = explode('.', $id);

  /** @var \Drupal\field\FieldConfigInterface $field */
  $field = FieldConfig::load($id);
  $this
    ->assertInstanceOf(FieldConfigInterface::class, $field);
  $this
    ->assertEquals($expected_label, $field
    ->label());
  $this
    ->assertEquals($expected_field_type, $field
    ->getType());
  $this
    ->assertEquals($expected_entity_type, $field
    ->getTargetEntityTypeId());
  $this
    ->assertEquals($expected_bundle, $field
    ->getTargetBundle());
  $this
    ->assertEquals($expected_name, $field
    ->getName());
  $this
    ->assertEquals($is_required, $field
    ->isRequired());
  $this
    ->assertEquals($expected_entity_type . '.' . $expected_name, $field
    ->getFieldStorageDefinition()
    ->id());
  $this
    ->assertEquals($expected_translatable, $field
    ->isTranslatable());
}