function MigrateVocabularyFieldTest::assertEntity

Same name in other branches
  1. 11.x core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php \Drupal\Tests\forum\Kernel\Migrate\d6\MigrateVocabularyFieldTest::assertEntity()

Asserts various aspects of a field_storage_config entity.

@internal

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 MigrateVocabularyFieldTest::assertEntity()
MigrateVocabularyFieldTest::testVocabularyField in core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php
Tests the Drupal 6 vocabulary-node type association migration.

File

core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateVocabularyFieldTest.php, line 67

Class

MigrateVocabularyFieldTest
Vocabulary field migration.

Namespace

Drupal\Tests\forum\Kernel\Migrate\d6

Code

protected function assertEntity(string $id, string $expected_type, bool $expected_translatable, int $expected_cardinality) : void {
    [
        $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.