You are here

public function CommerceMigrateTestTrait::assertProductEntity in Commerce Migrate 3.1.x

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

Asserts a product.

Parameters

int $id: The product id.

string $type: The product bundle.

int $owner_id: The uid for this billing profile.

string $title: The title of the product.

string $is_published: The published status of the product.

array $store_ids: The ids of the stores for this product.

array $variations: The variation of this product.

7 calls to CommerceMigrateTestTrait::assertProductEntity()
CommerceMigrateTestTrait::productTest in tests/src/Kernel/CommerceMigrateTestTrait.php
Helper to test a product and its variations.
NodeTest::testProduct in modules/ubercart/tests/src/Kernel/Migrate/uc6/NodeTest.php
Test product migration.
ProductTest::testProduct in modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php
Test product migration from CSV source file.
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.

... See full list

File

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

Class

CommerceMigrateTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

public function assertProductEntity($id, $type, $owner_id, $title, $is_published, array $store_ids, array $variations) {
  $product = Product::load($id);
  $this
    ->assertInstanceOf(Product::class, $product);
  $this
    ->assertSame($type, $product
    ->bundle());
  $this
    ->assertSame($owner_id, $product
    ->getOwnerId());
  $this
    ->assertSame($title, $product
    ->getTitle());
  $this
    ->assertSame($is_published, $product
    ->isPublished());
  $this
    ->assertSame($store_ids, $product
    ->getStoreIds());

  // The variations may not be in the same order, sort them.
  $actual_variations = $product
    ->getVariationIds();
  $this
    ->assertSame(asort($variations), asort($actual_variations));
}