diff --git a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTest.php b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTest.php
index b1e5399..0c2b67f 100644
--- a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTest.php
+++ b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTest.php
@@ -47,14 +47,56 @@ class ProductTest extends Commerce1TestBase {
}
/**
- * Test profile migration from Drupal 7 to 8.
+ * Test product migration from Drupal 7 to 8.
+ *
+ * @dataProvider productsProvider
*/
- public function testProduct() {
- $this->assertProductEntity(15, '1', 'Go green with Drupal Commerce Reusable Tote Bag', TRUE, ['1'], ['1']);
+ public function testProduct(array $product) {
+ // Test variations.
+ $variation_ids = [];
+ foreach ($product['variations'] as $variation) {
+ $variation_ids[] = $variation['variation_id'];
+ $productInstance = Product::load($product['product_id']);
+ $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']);
+ }
- $product = Product::load(15);
- $variation_id = $product->variations->target_id;
- $this->assertProductVariationEntity($variation_id, '0', 'TOT1-GRN-OS', '16.000000', 'USD', '1', 'Tote Bag 1', 'default');
+ // Test product itself.
+ $this->assertProductEntity($product['product_id'], $product['uid'], $product['title'], $product['published'], $product['store_ids'], $variation_ids);
+ }
+
+ /**
+ * Products data provider.
+ */
+ public function productsProvider() {
+ return [
+ 'go green' => [
+ [
+ 'product_id' => '15',
+ 'uid' => '1',
+ 'title' => 'Go green with Drupal Commerce Reusable Tote Bag',
+ 'published' => TRUE,
+ 'store_ids' => ['1'],
+ 'variations' => [
+ 'variation one' => [
+ 'variation_id' => '1',
+ 'uid' => '0',
+ 'sku' => 'TOT1-GRN-OS',
+ 'price' => '16.000000',
+ 'currency' => 'USD',
+ 'title' => 'Tote Bag 1',
+ 'order_item_type' => 'default',
+ ],
+ ],
+ ],
+ ],
+ ];
}
}
diff --git a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTypeTest.php b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTypeTest.php
index e760f4d..cc2f1bc 100644
--- a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTypeTest.php
+++ b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductTypeTest.php
@@ -37,22 +37,57 @@ class ProductTypeTest extends Commerce1TestBase {
/**
* Test product type migration from Drupal 7 to 8.
+ *
+ * @dataProvider productTypes
*/
- public function testProductType() {
- $description = 'A Bags & Cases is a content type which contain product variations.';
- $this->assertProductTypeEntity('bags_cases', 'Bags & Cases', $description);
-
- $description = 'A Tops is a content type which contain product variations.';
- $this->assertProductTypeEntity('tops', 'Tops', $description);
+ public function testProductType($id, $label, $description) {
+ $this->assertProductTypeEntity($id, $label, $description);
+ }
+ /**
+ * Test product type migration fields from Drupal 7 to 8.
+ *
+ * @dataProvider productTypeFields
+ */
+ public function testProductTypeFields($bundle, array $fields) {
/** @var \Drupal\Core\Entity\EntityFieldManager $field_manager */
- $field_manager = \Drupal::service('entity_field.manager');
- $field_definitions = $field_manager->getFieldDefinitions('commerce_product', 'tops');
+ $field_manager = $this->container->get('entity_field.manager');
+ $field_definitions = $field_manager->getFieldDefinitions('commerce_product', $bundle);
- // Check that stores, variations, and body were added.
- $this->assertTrue(isset($field_definitions['body']));
- $this->assertTrue(isset($field_definitions['variations']));
- $this->assertTrue(isset($field_definitions['stores']));
+ // Check that fields were added.
+ foreach ($fields as $field) {
+ $this->assertTrue(isset($field_definitions[$field]));
+ }
+ }
+
+ /**
+ * Data provider of product types.
+ */
+ public function productTypes() {
+ return [
+ 'bags' => [
+ 'id' => 'bags_cases',
+ 'label' => 'Bags & Cases',
+ 'description' => 'A Bags & Cases is a content type which contain product variations.',
+ ],
+ 'tops' => [
+ 'id' => 'tops',
+ 'label' => 'Tops',
+ 'description' => 'A Tops is a content type which contain product variations.',
+ ],
+ ];
+ }
+
+ /**
+ * Data provider of product type fields.
+ */
+ public function productTypeFields() {
+ return [
+ 'tops' => [
+ 'bundle' => 'tops',
+ 'fields' => ['body', 'variations', 'stores'],
+ ],
+ ];
}
}
diff --git a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductVariationTest.php b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductVariationTest.php
index 5c67c8b..6b0c165 100644
--- a/modules/commerce/tests/src/Kernel/Migrate/d7/ProductVariationTest.php
+++ b/modules/commerce/tests/src/Kernel/Migrate/d7/ProductVariationTest.php
@@ -40,19 +40,112 @@ class ProductVariationTest extends Commerce1TestBase {
/**
* Test product variation migration from Drupal 7 Commerce to Drupal 8.
+ *
+ * @dataProvider variationsProvider
*/
- public function testProductVariation() {
- $this->assertProductVariationEntity(1, '0', 'TOT1-GRN-OS', '16.000000', 'USD', '1', 'Tote Bag 1', 'default');
- $this->assertProductVariationEntity(11, '0', 'HAT1-GRY-OS', '16.000000', 'USD', '11', 'Hat 1', 'default');
- $this->assertProductVariationEntity(19, '0', 'SHO2-PRL-04', '40.000000', 'USD', '19', 'Shoe 2', 'default');
- $this->assertProductVariationEntity(20, '0', 'SHO2-PRL-05', '40.000000', 'USD', '20', 'Shoe 2', 'default');
- $this->assertProductVariationEntity(28, '0', 'USB-BLU-08', '11.990000', 'USD', '28', 'Storage 1', 'default');
- $this->assertProductVariationEntity(29, '0', 'USB-BLU-16', '17.990000', 'USD', '29', 'Storage 1', 'default');
- $this->assertProductVariationEntity(30, '0', 'USB-BLU-32', '29.990000', 'USD', '30', 'Storage 1', 'default');
+ public function testProductVariation(array $variation) {
+ $this->assertProductVariationEntity($variation['id'], $variation['uid'], $variation['sku'], $variation['price'], $variation['currency'], $variation['product_id'], $variation['variation_title'], $variation['variation_bundle']);
+ }
+ /**
+ * Test timestamps.
+ */
+ public function testTimestamps() {
$product = ProductVariation::load(1);
$this->assertEquals($product->getCreatedTime(), 1493287314);
$this->assertEquals($product->getChangedTime(), 1493287314);
}
+ /**
+ * Products data provider.
+ */
+ public function variationsProvider() {
+ return [
+ 'TOT1-GRN-OS' => [
+ [
+ 'id' => 1,
+ 'uid' => '0',
+ 'sku' => 'TOT1-GRN-OS',
+ 'price' => '16.000000',
+ 'currency' => 'USD',
+ 'product_id' => '1',
+ 'variation_title' => 'Tote Bag 1',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'HAT1-GRY-OS' => [
+ [
+ 'id' => 11,
+ 'uid' => '0',
+ 'sku' => 'HAT1-GRY-OS',
+ 'price' => '16.000000',
+ 'currency' => 'USD',
+ 'product_id' => '11',
+ 'variation_title' => 'Hat 1',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'SHO2-PRL-04' => [
+ [
+ 'id' => 19,
+ 'uid' => '0',
+ 'sku' => 'SHO2-PRL-04',
+ 'price' => '40.000000',
+ 'currency' => 'USD',
+ 'product_id' => '19',
+ 'variation_title' => 'Shoe 2',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'SHO2-PRL-05' => [
+ [
+ 'id' => 20,
+ 'uid' => '0',
+ 'sku' => 'SHO2-PRL-05',
+ 'price' => '40.000000',
+ 'currency' => 'USD',
+ 'product_id' => '20',
+ 'variation_title' => 'Shoe 2',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'USB-BLU-08' => [
+ [
+ 'id' => 28,
+ 'uid' => '0',
+ 'sku' => 'USB-BLU-08',
+ 'price' => '11.990000',
+ 'currency' => 'USD',
+ 'product_id' => '28',
+ 'variation_title' => 'Storage 1',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'USB-BLU-16' => [
+ [
+ 'id' => 29,
+ 'uid' => '0',
+ 'sku' => 'USB-BLU-16',
+ 'price' => '17.990000',
+ 'currency' => 'USD',
+ 'product_id' => '29',
+ 'variation_title' => 'Storage 1',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ 'USB-BLU-32' => [
+ [
+ 'id' => 30,
+ 'uid' => '0',
+ 'sku' => 'USB-BLU-32',
+ 'price' => '29.990000',
+ 'currency' => 'USD',
+ 'product_id' => '30',
+ 'variation_title' => 'Storage 1',
+ 'variation_bundle' => 'default',
+ ],
+ ],
+ ];
+ }
+
}
diff --git a/tests/src/Kernel/CommerceMigrateTestTrait.php b/tests/src/Kernel/CommerceMigrateTestTrait.php
index 721179f..5ba17a6 100644
--- a/tests/src/Kernel/CommerceMigrateTestTrait.php
+++ b/tests/src/Kernel/CommerceMigrateTestTrait.php
@@ -25,45 +25,45 @@ trait CommerceMigrateTestTrait {
*
* @param \Drupal\address\AddressInterface $address
* The address id.
- * @param string $expected_country_code
+ * @param string $country
* The country code.
- * @param string $expected_administrative_area
+ * @param string $administrative_area
* The administrative area.
- * @param string $expected_locality
+ * @param string $locality
* The locality.
- * @param string $expected_dependent_locality
+ * @param string $dependent_locality
* The dependent locality.
- * @param string $expected_postal_code
+ * @param string $postal_code
* The postal code.
- * @param string $expected_sorting_code
+ * @param string $sorting_code
* The sorting code.
- * @param string $expected_address_line_1
+ * @param string $address_line_1
* Address line 1.
- * @param string $expected_address_line_2
+ * @param string $address_line_2
* Address line 2.
- * @param string $expected_given_name
+ * @param string $given_name
* The given name.
- * @param string $expected_additional_name
+ * @param string $additional_name
* Any additional names.
- * @param string $expected_family_name
+ * @param string $family_name
* The family name.
- * @param string $expected_organization
+ * @param string $organization
* The organization string.
*/
- public function assertAddressItem(AddressInterface $address, $expected_country_code, $expected_administrative_area, $expected_locality, $expected_dependent_locality, $expected_postal_code, $expected_sorting_code, $expected_address_line_1, $expected_address_line_2, $expected_given_name, $expected_additional_name, $expected_family_name, $expected_organization) {
+ public function assertAddressItem(AddressInterface $address, $country, $administrative_area, $locality, $dependent_locality, $postal_code, $sorting_code, $address_line_1, $address_line_2, $given_name, $additional_name, $family_name, $organization) {
$this->assertInstanceOf(AddressItem::class, $address);
- $this->assertSame($expected_country_code, $address->getCountryCode());
- $this->assertSame($expected_administrative_area, $address->getAdministrativeArea());
- $this->assertSame($expected_locality, $address->getLocality());
- $this->assertSame($expected_dependent_locality, $address->getDependentLocality());
- $this->assertSame($expected_postal_code, $address->getPostalCode());
- $this->assertSame($expected_sorting_code, $address->getSortingCode());
- $this->assertSame($expected_address_line_1, $address->getAddressLine1());
- $this->assertSame($expected_address_line_2, $address->getAddressLine2());
- $this->assertSame($expected_given_name, $address->getGivenName());
- $this->assertSame($expected_additional_name, $address->getAdditionalName());
- $this->assertSame($expected_family_name, $address->getFamilyName());
- $this->assertSame($expected_organization, $address->getOrganization());
+ $this->assertSame($country, $address->getCountryCode());
+ $this->assertSame($administrative_area, $address->getAdministrativeArea());
+ $this->assertSame($locality, $address->getLocality());
+ $this->assertSame($dependent_locality, $address->getDependentLocality());
+ $this->assertSame($postal_code, $address->getPostalCode());
+ $this->assertSame($sorting_code, $address->getSortingCode());
+ $this->assertSame($address_line_1, $address->getAddressLine1());
+ $this->assertSame($address_line_2, $address->getAddressLine2());
+ $this->assertSame($given_name, $address->getGivenName());
+ $this->assertSame($additional_name, $address->getAdditionalName());
+ $this->assertSame($family_name, $address->getFamilyName());
+ $this->assertSame($organization, $address->getOrganization());
}
/**
@@ -71,24 +71,24 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The profile id.
- * @param int $expected_owner_id
+ * @param int $owner_id
* The uid for this billing profile.
- * @param string $expected_is_active
+ * @param string $is_active
* The active state of the profile.
- * @param string $expected_created_time
+ * @param string $created_time
* The time the profile was created..
- * @param string $expected_changed_time
+ * @param string $changed_time
* The time the profile was last changed.
*/
- public function assertBillingProfile($id, $expected_owner_id, $expected_is_active, $expected_created_time, $expected_changed_time) {
+ public function assertBillingProfile($id, $owner_id, $is_active, $created_time, $changed_time) {
$profile = Profile::load($id);
$this->assertNotNull($profile);
// Billing profiles are always 'customer' bundle.
$this->assertSame('customer', $profile->bundle());
- $this->assertSame($expected_owner_id, $profile->getOwnerId());
- $this->assertSame($expected_is_active, $profile->isActive());
- $this->assertSame($expected_created_time, ($profile->getCreatedTime()));
- $this->assertSame($expected_changed_time, $profile->getChangedTime());
+ $this->assertSame($owner_id, $profile->getOwnerId());
+ $this->assertSame($is_active, $profile->isActive());
+ $this->assertSame($created_time, ($profile->getCreatedTime()));
+ $this->assertSame($changed_time, $profile->getChangedTime());
}
/**
@@ -96,26 +96,26 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The currency id.
- * @param string $expected_currency_code
+ * @param string $currency_code
* The currency code.
- * @param string $expected_name
+ * @param string $name
* The name of the currency.
- * @param string $expected_numeric_code
+ * @param string $numeric_code
* The numeric code for the currency.
- * @param string $expected_fraction_digits
+ * @param string $fraction_digits
* The number of fraction digits for this currency.
- * @param string $expected_symbol
+ * @param string $currency_symbol
* The currency symbol.
*/
- public function assertCurrencyEntity($id, $expected_currency_code, $expected_name, $expected_numeric_code, $expected_fraction_digits, $expected_symbol) {
+ public function assertCurrencyEntity($id, $currency_code, $name, $numeric_code, $fraction_digits, $currency_symbol) {
/** @var \Drupal\commerce_price\Entity\CurrencyInterface $currency */
$currency = Currency::load($id);
$this->assertInstanceOf(CurrencyInterface::class, $currency);
- $this->assertSame($expected_currency_code, $currency->getCurrencyCode());
- $this->assertSame($expected_name, $currency->getName());
- $this->assertSame($expected_fraction_digits, $currency->getFractionDigits());
- $this->assertSame($expected_numeric_code, $currency->getNumericCode());
- $this->assertSame($expected_symbol, $currency->getSymbol());
+ $this->assertSame($currency_code, $currency->getCurrencyCode());
+ $this->assertSame($name, $currency->getName());
+ $this->assertSame($fraction_digits, $currency->getFractionDigits());
+ $this->assertSame($numeric_code, $currency->getNumericCode());
+ $this->assertSame($currency_symbol, $currency->getSymbol());
}
/**
@@ -123,38 +123,38 @@ trait CommerceMigrateTestTrait {
*
* @param string $id
* The order id.
- * @param string $expected_order_number
+ * @param string $order_number
* The order number.
- * @param string $expected_store_id
+ * @param string $store_id
* The store id.
- * @param string $expected_created_time
+ * @param string $created_time
* The time the order was created.
- * @param string $expected_changed_time
+ * @param string $changed_time
* The time the order was changed.
- * @param string $expected_email
+ * @param string $email
* The email address for this order.
- * @param string $expected_label
+ * @param string $label
* The label for this order.
- * @param string $expected_ip_address
+ * @param string $ip_address
* The ip address used to create this order.
- * @param string $expected_customer_id
+ * @param string $customer_id
* The customer id.
- * @param string $expected_placed_time
+ * @param string $placed_time
* The time the order was placed.
*/
- public function assertOrder($id, $expected_order_number, $expected_store_id, $expected_created_time, $expected_changed_time, $expected_email, $expected_label, $expected_ip_address, $expected_customer_id, $expected_placed_time) {
+ public function assertOrder($id, $order_number, $store_id, $created_time, $changed_time, $email, $label, $ip_address, $customer_id, $placed_time) {
$order = Order::load($id);
$this->assertInstanceOf(Order::class, $order);
- $this->assertSame($expected_order_number, $order->getOrderNumber());
- $this->assertSame($expected_store_id, $order->getStoreId());
- $this->assertSame($expected_created_time, $order->getCreatedTime());
- $this->assertSame($expected_changed_time, $order->getChangedTime());
- $this->assertSame($expected_email, $order->getEmail());
- $this->assertSame($expected_label, $order->getState()->getLabel());
+ $this->assertSame($order_number, $order->getOrderNumber());
+ $this->assertSame($store_id, $order->getStoreId());
+ $this->assertSame($created_time, $order->getCreatedTime());
+ $this->assertSame($changed_time, $order->getChangedTime());
+ $this->assertSame($email, $order->getEmail());
+ $this->assertSame($label, $order->getState()->getLabel());
$this->assertNotNull($order->getBillingProfile());
- $this->assertSame($expected_customer_id, $order->getCustomerId());
- $this->assertSame($expected_ip_address, $order->getIpAddress());
- $this->assertSame($expected_placed_time, $order->getPlacedTime());
+ $this->assertSame($customer_id, $order->getCustomerId());
+ $this->assertSame($ip_address, $order->getIpAddress());
+ $this->assertSame($placed_time, $order->getPlacedTime());
}
/**
@@ -162,34 +162,34 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The order item id.
- * @param int $expected_order_id
+ * @param int $order_id
* The order id for this item.
- * @param int $expected_purchased_entity_id
+ * @param int $purchased_entity_id
* The id of the purchased entity.
- * @param string $expected_quantity
+ * @param string $quantity
* The order quantity.
- * @param string $expected_title
+ * @param string $title
* The title of the item.
- * @param string $expected_unit_price_number
+ * @param string $unit_price
* The unit price of the item.
- * @param string $expected_unit_price_currency_code
+ * @param string $unit_price_currency
* The unit price currency code.
- * @param string $expected_total_price_number
+ * @param string $total_price
* The total price of this item.
- * @param string $expected_total_price_currency_code
+ * @param string $total_price_currency
* The total price currency code.
*/
- public function assertOrderItem($id, $expected_order_id, $expected_purchased_entity_id, $expected_quantity, $expected_title, $expected_unit_price_number, $expected_unit_price_currency_code, $expected_total_price_number, $expected_total_price_currency_code) {
+ public function assertOrderItem($id, $order_id, $purchased_entity_id, $quantity, $title, $unit_price, $unit_price_currency, $total_price, $total_price_currency) {
$order_item = OrderItem::load($id);
$this->assertInstanceOf(OrderItem::class, $order_item);
- $this->assertSame($expected_quantity, $order_item->getQuantity());
- $this->assertEquals($expected_title, $order_item->getTitle());
- $this->assertEquals($expected_unit_price_number, $order_item->getUnitPrice()->getNumber());
- $this->assertEquals($expected_unit_price_currency_code, $order_item->getUnitPrice()->getCurrencyCode());
- $this->assertEquals($expected_total_price_number, $order_item->getTotalPrice()->getNumber());
- $this->assertEquals($expected_total_price_currency_code, $order_item->getTotalPrice()->getCurrencyCode());
- $this->assertEquals($expected_purchased_entity_id, $order_item->getPurchasedEntityId());
- $this->assertEquals($expected_order_id, $order_item->getOrderId());
+ $this->assertSame($quantity, $order_item->getQuantity());
+ $this->assertEquals($title, $order_item->getTitle());
+ $this->assertEquals($unit_price, $order_item->getUnitPrice()->getNumber());
+ $this->assertEquals($unit_price_currency, $order_item->getUnitPrice()->getCurrencyCode());
+ $this->assertEquals($total_price, $order_item->getTotalPrice()->getNumber());
+ $this->assertEquals($total_price_currency, $order_item->getTotalPrice()->getCurrencyCode());
+ $this->assertEquals($purchased_entity_id, $order_item->getPurchasedEntityId());
+ $this->assertEquals($order_id, $order_item->getOrderId());
}
/**
@@ -197,25 +197,25 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The product id.
- * @param int $expected_owner_id
+ * @param int $owner_id
* The uid for this billing profile.
- * @param string $expected_title
+ * @param string $title
* The title of the product.
- * @param string $expected_is_published
+ * @param string $is_published
* The published status of the product.
- * @param array $expected_store_ids
+ * @param array $store_ids
* The ids of the stores for this product.
- * @param array $expected_variations
+ * @param array $variations
* The variation of this product.
*/
- public function assertProductEntity($id, $expected_owner_id, $expected_title, $expected_is_published, array $expected_store_ids, array $expected_variations) {
+ public function assertProductEntity($id, $owner_id, $title, $is_published, array $store_ids, array $variations) {
$product = Product::load($id);
$this->assertInstanceOf(Product::class, $product);
- $this->assertSame($expected_owner_id, $product->getOwnerId());
- $this->assertSame($expected_title, $product->getTitle());
- $this->assertSame($expected_is_published, $product->isPublished());
- $this->assertSame($expected_store_ids, $product->getStoreIds());
- $this->assertSame($expected_variations, $product->getVariationIds());
+ $this->assertSame($owner_id, $product->getOwnerId());
+ $this->assertSame($title, $product->getTitle());
+ $this->assertSame($is_published, $product->isPublished());
+ $this->assertSame($store_ids, $product->getStoreIds());
+ $this->assertSame($variations, $product->getVariationIds());
}
/**
@@ -223,16 +223,16 @@ trait CommerceMigrateTestTrait {
*
* @param string $id
* The product type id.
- * @param string $expected_label
+ * @param string $label
* The expected label.
- * @param string $expected_description
+ * @param string $description
* The expected description.
*/
- public function assertProductTypeEntity($id, $expected_label, $expected_description) {
+ public function assertProductTypeEntity($id, $label, $description) {
$product_type = ProductType::load($id);
$this->assertInstanceOf(ProductType::class, $product_type);
- $this->assertSame($expected_label, $product_type->label());
- $this->assertSame($expected_description, $product_type->getDescription());
+ $this->assertSame($label, $product_type->label());
+ $this->assertSame($description, $product_type->getDescription());
}
/**
@@ -240,31 +240,31 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The product variation id.
- * @param int $expected_owner_id
+ * @param int $owner_id
* The uid for this billing profile.
- * @param string $expected_sku
+ * @param string $sku
* The SKU.
- * @param string $expected_price_number
+ * @param string $price_number
* The price.
- * @param string $expected_price_currency_code
+ * @param string $price_currency
* The currency code.
- * @param string $expected_product_id
+ * @param string $product_id
* The id of the product.
- * @param string $expected_order_item_title
+ * @param string $variation_title
* The title.
- * @param string $expected_order_item_type_id
+ * @param string $variation_bundle
* The order item type.
*/
- public function assertProductVariationEntity($id, $expected_owner_id, $expected_sku, $expected_price_number, $expected_price_currency_code, $expected_product_id, $expected_order_item_title, $expected_order_item_type_id) {
+ public function assertProductVariationEntity($id, $owner_id, $sku, $price_number, $price_currency, $product_id, $variation_title, $variation_bundle) {
$variation = ProductVariation::load($id);
$this->assertInstanceOf(ProductVariation::class, $variation);
- $this->assertSame($expected_owner_id, $variation->getOwnerId());
- $this->assertSame($expected_sku, $variation->getSku());
- $this->assertSame($expected_price_number, $variation->getPrice()->getNumber());
- $this->assertSame($expected_price_currency_code, $variation->getPrice()->getCurrencyCode());
- $this->assertSame($expected_product_id, $variation->getProductId());
- $this->assertSame($expected_order_item_title, $variation->getOrderItemTitle());
- $this->assertSame($expected_order_item_type_id, $variation->getOrderItemTypeId());
+ $this->assertSame($owner_id, $variation->getOwnerId());
+ $this->assertSame($sku, $variation->getSku());
+ $this->assertSame($price_number, $variation->getPrice()->getNumber());
+ $this->assertSame($price_currency, $variation->getPrice()->getCurrencyCode());
+ $this->assertSame($product_id, $variation->getProductId());
+ $this->assertSame($variation_title, $variation->getOrderItemTitle());
+ $this->assertSame($variation_bundle, $variation->getOrderItemTypeId());
}
/**
@@ -272,19 +272,19 @@ trait CommerceMigrateTestTrait {
*
* @param string $id
* The product variation type.
- * @param string $expected_label
+ * @param string $label
* The expected label.
- * @param string $expected_order_item_type_id
+ * @param string $variation_id
* The expected order item type id.
- * @param bool $expected_should_generate_title
+ * @param bool $is_title_generated
* The expected indicator that a title is generated.
*/
- public function assertProductVariationTypeEntity($id, $expected_label, $expected_order_item_type_id, $expected_should_generate_title) {
+ public function assertProductVariationTypeEntity($id, $label, $variation_id, $is_title_generated) {
$variation_type = ProductVariationType::load($id);
$this->assertInstanceOf(ProductVariationType::class, $variation_type);
- $this->assertSame($expected_label, $variation_type->label());
- $this->assertSame($expected_order_item_type_id, $variation_type->getOrderItemTypeId());
- $this->assertSame($expected_should_generate_title, $variation_type->shouldGenerateTitle());
+ $this->assertSame($label, $variation_type->label());
+ $this->assertSame($variation_id, $variation_type->getOrderItemTypeId());
+ $this->assertSame($is_title_generated, $variation_type->shouldGenerateTitle());
}
/**
@@ -292,26 +292,26 @@ trait CommerceMigrateTestTrait {
*
* @param int $id
* The store id.
- * @param string $expected_name
+ * @param string $name
* The name of the store.
- * @param string $expected_email
+ * @param string $email
* The email address of the store.
- * @param string $expected_default_currency_code
+ * @param string $default_currency
* The default currency code of the store.
- * @param string $expected_bundle
+ * @param string $bundle
* The bundle.
- * @param string $expected_owner_id
+ * @param string $owner_id
* The owner id.
*/
- public function assertStoreEntity($id, $expected_name, $expected_email, $expected_default_currency_code, $expected_bundle, $expected_owner_id) {
+ public function assertStoreEntity($id, $name, $email, $default_currency, $bundle, $owner_id) {
$store = Store::load($id);
$this->assertNotNull($store);
$this->assertInstanceOf(Store::class, $store);
- $this->assertSame($expected_name, $store->getName());
- $this->assertSame($expected_email, $store->getEmail());
- $this->assertSame($expected_default_currency_code, $store->getDefaultCurrencyCode());
- $this->assertSame($expected_bundle, $store->bundle());
- $this->assertSame($expected_owner_id, $store->getOwnerId());
+ $this->assertSame($name, $store->getName());
+ $this->assertSame($email, $store->getEmail());
+ $this->assertSame($default_currency, $store->getDefaultCurrencyCode());
+ $this->assertSame($bundle, $store->bundle());
+ $this->assertSame($owner_id, $store->getOwnerId());
}
}