You are here

protected function CommerceMigrateCoreTestTrait::assertTermEntity in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/CommerceMigrateCoreTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateCoreTestTrait::assertTermEntity()
  2. 3.0.x tests/src/Kernel/CommerceMigrateCoreTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateCoreTestTrait::assertTermEntity()

Validate a migrated term contains the expected values.

Parameters

string $id: Entity ID to load and check.

string $expected_label: The label the migrated entity should have.

string $expected_vid: The parent vocabulary the migrated entity should have.

string $expected_description: The description the migrated entity should have.

string $expected_format: The format the migrated entity should have.

int $expected_weight: The weight the migrated entity should have.

array $expected_parents: The parent terms the migrated entity should have.

5 calls to CommerceMigrateCoreTestTrait::assertTermEntity()
NodeTest::testNode in modules/commerce/tests/src/Kernel/Migrate/commerce1/NodeTest.php
Test node migration from Commerce 1 to Commerce Drupal 8.
TaxonomyCategoriesTermTest::testTaxonomyTerm in modules/woocommerce/tests/src/Kernel/Migrate/woo3/TaxonomyCategoriesTermTest.php
Tests the WooCommerce taxonomy term to Drupal 8 migration.
TaxonomyTagTermTest::testTaxonomyTerm in modules/woocommerce/tests/src/Kernel/Migrate/woo3/TaxonomyTagTermTest.php
Tests the WooCommerce taxonomy term to Drupal 8 migration.
TaxonomyTermTest::testTaxonomyTerm in modules/shopify/tests/src/Kernel/Migrate/TaxonomyTermTest.php
Tests the shopify taxonomy term to Drupal 8 migration.
TaxonomyTermTest::testTaxonomyTerm in modules/magento/tests/src/Kernel/Migrate/magento2/TaxonomyTermTest.php
Tests the Drupal 7 taxonomy term to Drupal 8 migration.

File

tests/src/Kernel/CommerceMigrateCoreTestTrait.php, line 99

Class

CommerceMigrateCoreTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

protected function assertTermEntity($id, $expected_label, $expected_vid, $expected_description = '', $expected_format = NULL, $expected_weight = 0, array $expected_parents = []) {

  /** @var \Drupal\taxonomy\TermInterface $entity */
  $entity = Term::load($id);
  $this
    ->assertInstanceOf(TermInterface::class, $entity);
  $this
    ->assertEquals($expected_label, $entity
    ->label());
  $this
    ->assertEquals($expected_vid, $entity
    ->bundle());
  $this
    ->assertEquals($expected_description, $entity
    ->getDescription());
  $this
    ->assertEquals($expected_format, $entity
    ->getFormat());
  $this
    ->assertEquals($expected_weight, $entity
    ->getWeight());
  $tmp = [];
  foreach ($expected_parents as $parent) {
    $tmp[] = [
      'target_id' => $parent,
    ];
  }
  $this
    ->assertEquals($tmp, $entity
    ->get('parent')
    ->getValue());
  $this
    ->assertHierarchy($expected_vid, $id, $expected_parents);
}