You are here

public function OrderTest::testOrder in Commerce Migrate 3.1.x

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

Test line item migration from Drupal 7 to 8.

1 call to OrderTest::testOrder()
OrderRollbackTest::testOrder in modules/commerce/tests/src/Kernel/Migrate/commerce1/OrderRollbackTest.php
Test order migration from Drupal 7 to 8.
1 method overrides OrderTest::testOrder()
OrderRollbackTest::testOrder in modules/commerce/tests/src/Kernel/Migrate/commerce1/OrderRollbackTest.php
Test order migration from Drupal 7 to 8.

File

modules/commerce/tests/src/Kernel/Migrate/commerce1/OrderTest.php, line 53

Class

OrderTest
Tests order migration.

Namespace

Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1

Code

public function testOrder() {
  $order = [
    'id' => 1,
    'type' => 'default',
    'number' => '1',
    'store_id' => '1',
    'created_time' => '1493287432',
    // Changed time is overwritten by Commerce when the status is Draft. The
    // source changed time is '1508452606'.
    'changed_time' => '1508452606',
    'completed_time' => NULL,
    'email' => 'customer@example.com',
    'ip_address' => '10.1.1.2',
    'customer_id' => '4',
    'placed_time' => NULL,
    'total_price' => '39.000000',
    'total_price_currency' => 'USD',
    'adjustments' => [
      new Adjustment([
        'type' => 'shipping',
        'label' => 'Express shipping: 1 business day',
        'amount' => new Price('15', 'USD'),
        'percentage' => NULL,
        'source_id' => 'custom',
        'included' => FALSE,
        'locked' => TRUE,
      ]),
    ],
    'label_value' => 'draft',
    'label_rendered' => 'Draft',
    'order_items_ids' => [
      '1',
      '2',
    ],
    'billing_profile' => [
      '4',
      '4',
    ],
    'data' => [
      [
        'paid_event_dispatched' => FALSE,
      ],
    ],
    'cart' => '1',
  ];
  $this
    ->assertOrder($order);
  $order = [
    'id' => 2,
    'type' => 'default',
    'number' => '2',
    'store_id' => '1',
    'created_time' => '1493287435',
    'changed_time' => '1508452654',
    'completed_time' => '1508452654',
    'email' => 'customer@example.com',
    'ip_address' => '10.1.1.2',
    'customer_id' => '4',
    'placed_time' => '1493287435',
    'total_price' => '120.000000',
    'total_price_currency' => 'USD',
    'adjustments' => [
      new Adjustment([
        'type' => 'shipping',
        'label' => 'Free shipping: 5 - 8 business days',
        'amount' => new Price('0', 'USD'),
        'percentage' => NULL,
        'source_id' => 'custom',
        'included' => FALSE,
        'locked' => TRUE,
      ]),
    ],
    'label_value' => 'completed',
    'label_rendered' => 'Completed',
    'order_items_ids' => [
      '3',
      '4',
      '5',
      '6',
      '7',
    ],
    'billing_profile' => [
      '6',
      '6',
    ],
    'data' => [],
    'cart' => '0',
  ];
  $this
    ->assertOrder($order);
  $order = [
    'id' => 3,
    'type' => 'default',
    'number' => '3',
    'store_id' => '1',
    'created_time' => '1493287438',
    'changed_time' => '1508452668',
    'completed_time' => '1508452668',
    'email' => 'customer@example.com',
    'ip_address' => '10.1.1.2',
    'customer_id' => '4',
    'placed_time' => '1493287438',
    'total_price' => '41.490000',
    'total_price_currency' => 'USD',
    'adjustments' => [
      new Adjustment([
        'type' => 'shipping',
        'label' => 'Express shipping: 1 business day',
        'amount' => new Price('1.5', 'USD'),
        'percentage' => NULL,
        'source_id' => 'custom',
        'included' => FALSE,
        'locked' => TRUE,
      ]),
    ],
    'label_value' => 'completed',
    'label_rendered' => 'Completed',
    'order_items_ids' => [
      '8',
      '9',
      '10',
    ],
    'billing_profile' => [
      '8',
      '8',
    ],
    'data' => [],
    'cart' => '0',
  ];
  $this
    ->assertOrder($order);
  $order = [
    'id' => 4,
    'type' => 'default',
    'number' => '4',
    'store_id' => '1',
    'created_time' => '1543271966',
    'changed_time' => '1543271966',
    'completed_time' => '1543271966',
    'email' => 'CommerceKickstart@example.com',
    'ip_address' => '172.19.0.2',
    'customer_id' => '1',
    'placed_time' => '1543271966',
    'total_price' => '40.380000',
    'total_price_currency' => 'USD',
    'adjustments' => [
      new Adjustment([
        'type' => 'shipping',
        'label' => 'Express shipping: 1 business day',
        'amount' => new Price('13.5', 'USD'),
        'percentage' => NULL,
        'source_id' => 'custom',
        'included' => FALSE,
        'locked' => TRUE,
      ]),
    ],
    'label_value' => 'completed',
    'label_rendered' => 'Completed',
    'order_items_ids' => [
      '14',
    ],
    'billing_profile' => [
      '10',
      '10',
    ],
    'data' => [],
    'cart' => '0',
  ];
  $this
    ->assertOrder($order);

  // Test billing profile.
  $order = Order::load(1);
  $profile = $order
    ->getBillingProfile();
  $this
    ->assertInstanceOf(Profile::class, $profile);
  $this
    ->assertEquals($profile
    ->bundle(), 'customer');
  $this
    ->assertEquals($profile
    ->isPublished(), TRUE);

  // Test store.
  $this
    ->assertEquals(\Drupal::service('commerce_store.default_store_resolver')
    ->resolve()
    ->id(), $order
    ->getStoreId());
}