You are here

public function CommerceMigrateTestTrait::assertProductVariationEntity in Commerce Migrate 3.0.x

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

Asserts a product variation.

Parameters

array $product_variation: An array of product variation information.

  • id: The product variation id.
  • type: The product variation bundle.
  • uid_id: The uid for this billing profile.
  • sku: The SKU.
  • price_number: The price
  • price_currency: The currency code.
  • product_id: The id of the product.
  • title: The title.
  • order_item_type_id: The order item type.
  • created_time: The title.
  • changed_time: The order item type.
  • attributes: An array of attribute name and values.
11 calls to CommerceMigrateTestTrait::assertProductVariationEntity()
CommerceMigrateTestTrait::productVariationTest in tests/src/Kernel/CommerceMigrateTestTrait.php
Helper to test a product is linked to its variations.
NodeTest::testProduct in modules/ubercart/tests/src/Kernel/Migrate/uc6/NodeTest.php
Test product migration.
ProductTest::testProduct in modules/magento/tests/src/Kernel/Migrate/magento2/ProductTest.php
Test product migration.
ProductTest::testProduct in modules/ubercart/tests/src/Kernel/Migrate/uc7/ProductTest.php
Test product migration.
ProductTest::testProduct in modules/ubercart/tests/src/Kernel/Migrate/uc6/ProductTest.php
Test product migration.

... See full list

File

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

Class

CommerceMigrateTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

public function assertProductVariationEntity(array $product_variation) {
  $variation = ProductVariation::load($product_variation['id']);
  $this
    ->assertInstanceOf(ProductVariation::class, $variation);
  $this
    ->assertSame($product_variation['type'], $variation
    ->bundle());
  $this
    ->assertSame($product_variation['uid'], $variation
    ->getOwnerId());
  $this
    ->assertSame($product_variation['sku'], $variation
    ->getSku());
  $formatted_number = $this
    ->formatNumber($product_variation['price'], $variation
    ->getPrice()
    ->getNumber());
  $this
    ->assertSame($formatted_number['expected'], $formatted_number['actual']);
  $this
    ->assertSame($product_variation['currency'], $variation
    ->getPrice()
    ->getCurrencyCode());
  $this
    ->assertSame($product_variation['product_id'], $variation
    ->getProductId());
  $this
    ->assertSame($product_variation['title'], $variation
    ->getOrderItemTitle());
  $this
    ->assertSame($product_variation['order_item_type_id'], $variation
    ->getOrderItemTypeId());
  if ($product_variation['created_time'] != NULL) {
    $this
      ->assertSame($product_variation['created_time'], $variation
      ->getCreatedTime());
  }
  if ($product_variation['changed_time'] != NULL) {
    $this
      ->assertSame($product_variation['changed_time'], $variation
      ->getChangedTime());
  }
}