You are here

public function ProductDeriverTest::testProductMigrations in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductDeriverTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductDeriverTest::testProductMigrations()
  2. 3.0.x modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductDeriverTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\ProductDeriverTest::testProductMigrations()

Test product variation migrations with commerce_product enabled.

File

modules/commerce/tests/src/Kernel/Migrate/commerce1/ProductDeriverTest.php, line 39

Class

ProductDeriverTest
Test Product Variation Deriver.

Namespace

Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1

Code

public function testProductMigrations() {

  // Create the product variation derivatives.
  $migrations = $this->pluginManager
    ->createInstances([
    'commerce1_product',
  ]);

  // Test that the variation for drinks exists.
  $this
    ->assertArrayHasKey('commerce1_product:drinks', $migrations, "Commerce product migrations exist after commerce_product installed");

  // Test that the fields for bags & cases exist in the show migration.

  /** @var \Drupal\migrate\Plugin\migration $migration */
  $migration = $migrations['commerce1_product:bags_cases'];
  $process = $migration
    ->getProcess();
  $this
    ->assertArrayHasKey('field_collection', $process, "Commerce product bags and cases has collection field.");
  $this
    ->assertArrayHasKey('field_category', $process, "Commerce product bags and cases has category field.");
  $this
    ->assertArrayHasKey('field_gender', $process, "Commerce product bags and cases has gender field.");
  $this
    ->assertArrayHasKey('field_brand', $process, "Commerce product bags and cases has brand field.");
}