You are here

public function CommerceMigrateTestTrait::productVariationTest in Commerce Migrate 8.2

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

Helper to test a product is linked to its variations.

Parameters

array $product: Product and product variation data.

1 call to CommerceMigrateTestTrait::productVariationTest()
CommerceMigrateTestTrait::productTest in tests/src/Kernel/CommerceMigrateTestTrait.php
Helper to test a product and its variations.

File

tests/src/Kernel/CommerceMigrateTestTrait.php, line 881

Class

CommerceMigrateTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

public function productVariationTest(array $product) {

  // Test variations.
  $productInstance = Product::load($product['product_id']);
  foreach ($product['variations'] as $variation) {
    $found = FALSE;
    foreach ($productInstance->variations as $variationInstance) {
      if ($variation['variation_id'] == $variationInstance->target_id) {
        $found = TRUE;
      }
    }
    $this
      ->assertTrue($found, "No variation exists for variation_id: {$variation['variation_id']}");
    $this
      ->assertProductVariationEntity($variation['variation_id'], $variation['uid'], $variation['sku'], $variation['price'], $variation['currency'], $product['product_id'], $variation['title'], $variation['order_item_type'], $variation['created_time'], $variation['changed_time']);
  }
}