You are here

public function OrderAdminTest::testEditOrderWithDeletedCustomer in Commerce Core 8.2

Tests editing an order after the customer was deleted.

File

modules/order/tests/src/FunctionalJavascript/OrderAdminTest.php, line 275

Class

OrderAdminTest
Tests the order admin UI.

Namespace

Drupal\Tests\commerce_order\FunctionalJavascript

Code

public function testEditOrderWithDeletedCustomer() {
  $customer = $this
    ->drupalCreateUser();
  $profile = Profile::create([
    'type' => 'customer',
    'uid' => 0,
    'address' => [
      'country_code' => 'US',
      'postal_code' => '53177',
      'locality' => 'Milwaukee',
      'address_line1' => 'Pabst Blue Ribbon Dr',
      'administrative_area' => 'WI',
      'given_name' => 'Frederick',
      'family_name' => 'Pabst',
    ],
  ]);
  $profile
    ->save();
  $order_item = OrderItem::create([
    'type' => 'default',
    'unit_price' => [
      'number' => '999',
      'currency_code' => 'USD',
    ],
  ]);
  $order_item
    ->save();
  $order = Order::create([
    'type' => 'default',
    'state' => 'completed',
    'uid' => $customer
      ->id(),
    'store_id' => $this->store,
    'billing_profile' => $profile,
    'order_items' => [
      $order_item,
    ],
  ]);
  $order
    ->save();
  $customer
    ->delete();
  $this
    ->drupalGet($order
    ->toUrl('edit-form'));
  $this
    ->submitForm([], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('The order has been successfully saved.');
}