You are here

public function ProductVariationRollbackTest::testProductVariation in Commerce Migrate 3.0.x

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

Test product migration rollback.

Overrides ProductVariationTest::testProductVariation

File

modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductVariationRollbackTest.php, line 29

Class

ProductVariationRollbackTest
Tests rollback of product variation migration..

Namespace

Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7

Code

public function testProductVariation() {

  // Rollback the product variations.
  $this
    ->executeRollbacks([
    'uc7_product_variation',
  ]);
  $product_variation_ids = [
    1,
    2,
    3,
  ];
  foreach ($product_variation_ids as $product_variation_id) {
    $product_variation = ProductVariation::load($product_variation_id);
    $this
      ->assertNull($product_variation, "Product variation {$product_variation_id} exists.");
  }
  for ($id = 1; $id <= 3; $id++) {
    $product_variation = ProductVariation::load($id);
    $this
      ->assertNull($product_variation, "Product variation {$id} exists.");
  }

  // Migrate products.
  $this
    ->migrateProducts();
  for ($id = 1; $id <= 3; $id++) {
    $product = Product::load($id);
    $this
      ->assertNotNull($product, "Product {$id} does not exist.");
  }
  for ($id = 4; $id <= 6; $id++) {
    $product_variation = ProductVariation::load($id);
    $this
      ->assertNotNull($product_variation, "Product variation {$id} does not exist.");
  }

  // Rollback the product variations.
  $this
    ->executeRollbacks([
    'uc7_product_variation',
  ]);
  for ($id = 4; $id <= 6; $id++) {
    $product_variation = ProductVariation::load($id);
    $this
      ->assertNull($product_variation, "Product variation {$id} exists.");
  }
  for ($id = 1; $id <= 3; $id++) {
    $product = Product::load($id);
    $this
      ->assertNotNull($product, "Product {$id} does not exist.");
  }
  $this
    ->migrateProductVariations();
  for ($id = 1; $id <= 3; $id++) {
    $product = Product::load($id);
    $this
      ->assertNotNull($product, "Product {$id} does not exist.");
  }
  for ($id = 7; $id <= 9; $id++) {
    $product_variation = ProductVariation::load($id);
    $this
      ->assertNotNull($product_variation, "Product variation {$id} does not exist.");
  }
}