You are here

public function OrderAdminTest::testDeleteOrder in Commerce Core 8.2

Tests deleting an order.

File

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

Class

OrderAdminTest
Tests the order admin UI.

Namespace

Drupal\Tests\commerce_order\FunctionalJavascript

Code

public function testDeleteOrder() {
  $order = $this
    ->createEntity('commerce_order', [
    'type' => 'default',
    'mail' => $this->loggedInUser
      ->getEmail(),
    'uid' => $this->loggedInUser,
    'store_id' => $this->store,
  ]);
  $this
    ->drupalGet($order
    ->toUrl('delete-form'));
  $this
    ->assertSession()
    ->pageTextContains(t('Are you sure you want to delete the order @label?', [
    '@label' => $order
      ->label(),
  ]));
  $this
    ->assertSession()
    ->pageTextContains('This action cannot be undone.');
  $this
    ->submitForm([], t('Delete'));
  $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_order')
    ->resetCache([
    $order
      ->id(),
  ]);
  $order_exists = (bool) Order::load($order
    ->id());
  $this
    ->assertEmpty($order_exists);
}