You are here

protected function AttributeFieldTest::assertEntity in Commerce Migrate 3.0.x

Same name in this branch
  1. 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc7/AttributeFieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\AttributeFieldTest::assertEntity()
  2. 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc6/AttributeFieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\AttributeFieldTest::assertEntity()
Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Migrate/uc6/AttributeFieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\AttributeFieldTest::assertEntity()
  2. 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/AttributeFieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\AttributeFieldTest::assertEntity()

Asserts various aspects of a field_storage_config entity.

Parameters

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

string $type: The expected field type.

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

int $cardinality: The expected cardinality of the field.

array $dependencies: The field's dependencies.

1 call to AttributeFieldTest::assertEntity()
AttributeFieldTest::testAttribute in modules/ubercart/tests/src/Kernel/Migrate/uc6/AttributeFieldTest.php
Test attribute field storage migration.

File

modules/ubercart/tests/src/Kernel/Migrate/uc6/AttributeFieldTest.php, line 52

Class

AttributeFieldTest
Tests attribute field storage migration.

Namespace

Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6

Code

protected function assertEntity($id, $type, $translatable, $cardinality, array $dependencies) {
  list($entity_type) = explode('.', $id);

  /** @var \Drupal\field\FieldStorageConfigInterface $field */
  $field = FieldStorageConfig::load($id);
  $this
    ->assertTrue($field instanceof FieldStorageConfigInterface);
  $this
    ->assertSame($type, $field
    ->getType());
  $this
    ->assertEquals($translatable, $field
    ->isTranslatable());
  $this
    ->assertSame($entity_type, $field
    ->getTargetEntityTypeId());
  $this
    ->assertSame($dependencies, $field
    ->getDependencies());
  if ($cardinality === 1) {
    $this
      ->assertFalse($field
      ->isMultiple());
  }
  else {
    $this
      ->assertTrue($field
      ->isMultiple());
  }
  $this
    ->assertSame($cardinality, $field
    ->getCardinality());
}