You are here

protected function Commerce1TestBase::migrateOrdersWithCart in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/commerce/tests/src/Kernel/Migrate/commerce1/Commerce1TestBase.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\Commerce1TestBase::migrateOrdersWithCart()
  2. 3.0.x modules/commerce/tests/src/Kernel/Migrate/commerce1/Commerce1TestBase.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\Commerce1TestBase::migrateOrdersWithCart()

Executes order migration with the cart enabled.

Required modules:

  • commerce_order.
  • commerce_price.
  • commerce_product.
  • commerce_store.
  • migrate_plus.
  • path.
1 call to Commerce1TestBase::migrateOrdersWithCart()
OrderTest::setUp in modules/commerce/tests/src/Kernel/Migrate/commerce1/OrderTest.php

File

modules/commerce/tests/src/Kernel/Migrate/commerce1/Commerce1TestBase.php, line 122

Class

Commerce1TestBase
Base class for Commerce 1 migration tests.

Namespace

Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1

Code

protected function migrateOrdersWithCart() {
  $this
    ->migrateOrderItems();
  $this
    ->migrateStore();

  // Installing the cart requires that the store has a country code.

  /** @var \Drupal\commerce_store\Entity\Store $store */
  $store = \Drupal::entityTypeManager()
    ->getStorage('commerce_store')
    ->load(1);
  $address = $store
    ->getAddress();
  $address->country_code = 'NZ';
  $address->address_line1 = '123 Nowhere St';
  $address->locality = 'Wellington';
  $store
    ->setAddress($address);
  $store
    ->save();
  $this
    ->installCommerceCart();
  $this
    ->migrateProfiles();
  $this
    ->executeMigrations([
    'commerce1_product_variation_type',
    'commerce1_product_variation',
    'commerce1_order_item_type',
    'commerce1_order_item',
    'commerce1_order',
  ]);
}