function MigrateFieldTest::assertEntity

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldTest::assertEntity()
  2. 10 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldTest::assertEntity()
  3. 11.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldTest::assertEntity()

Asserts various aspects of a field_storage_config entity.

Parameters

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

string $expected_type: The expected field type.

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

int $expected_cardinality: The expected cardinality of the field.

1 call to MigrateFieldTest::assertEntity()
MigrateFieldTest::testFields in core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php
Tests migrating D7 fields to field_storage_config entities.

File

core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldTest.php, line 55

Class

MigrateFieldTest
Migrates Drupal 7 fields.

Namespace

Drupal\Tests\field\Kernel\Migrate\d7

Code

protected function assertEntity($id, $expected_type, $expected_translatable, $expected_cardinality) {
    list($expected_entity_type, $expected_name) = explode('.', $id);
    
    /** @var \Drupal\field\FieldStorageConfigInterface $field */
    $field = FieldStorageConfig::load($id);
    $this->assertInstanceOf(FieldStorageConfigInterface::class, $field);
    $this->assertEquals($expected_name, $field->getName());
    $this->assertEquals($expected_type, $field->getType());
    $this->assertEquals($expected_translatable, $field->isTranslatable());
    $this->assertEquals($expected_entity_type, $field->getTargetEntityTypeId());
    if ($expected_cardinality === 1) {
        $this->assertFalse($field->isMultiple());
    }
    else {
        $this->assertTrue($field->isMultiple());
    }
    $this->assertEquals($expected_cardinality, $field->getCardinality());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.