You are here

protected function MigrateFieldTest::assertEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php \Drupal\field\Tests\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.

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

integer $expected_cardinality: The expected cardinality of the field.

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

File

core/modules/field/src/Tests/Migrate/d7/MigrateFieldTest.php, line 61
Contains \Drupal\field\Tests\Migrate\d7\MigrateFieldTest.

Class

MigrateFieldTest
Migrates Drupal 7 fields.

Namespace

Drupal\field\Tests\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
    ->assertTrue($field instanceof FieldStorageConfigInterface);
  $this
    ->assertIdentical($expected_name, $field
    ->getName());
  $this
    ->assertIdentical($expected_type, $field
    ->getType());

  // FieldStorageConfig::$translatable is TRUE by default, so it is useful
  // to test for FALSE here.
  $this
    ->assertEqual($expected_translatable, $field
    ->isTranslatable());
  $this
    ->assertIdentical($expected_entity_type, $field
    ->getTargetEntityTypeId());
  if ($expected_cardinality === 1) {
    $this
      ->assertFalse($field
      ->isMultiple());
  }
  else {
    $this
      ->assertTrue($field
      ->isMultiple());
  }
  $this
    ->assertIdentical($expected_cardinality, $field
    ->getCardinality());
}