You are here

public function ShippingMethodTest::testShippingMethodDeletion in Commerce Shipping 8.2

Tests deleting a shipping method.

File

tests/src/FunctionalJavascript/ShippingMethodTest.php, line 125

Class

ShippingMethodTest
Tests the shipping method UI.

Namespace

Drupal\Tests\commerce_shipping\FunctionalJavascript

Code

public function testShippingMethodDeletion() {
  $shipping_method = $this
    ->createEntity('commerce_shipping_method', [
    'name' => $this
      ->randomMachineName(8),
  ]);
  $this
    ->drupalGet($shipping_method
    ->toUrl('delete-form'));
  $this
    ->assertSession()
    ->pageTextContains('This action cannot be undone.');
  $this
    ->submitForm([], t('Delete'));
  $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_shipping_method')
    ->resetCache([
    $shipping_method
      ->id(),
  ]);
  $shipping_method_exists = (bool) ShippingMethod::load($shipping_method
    ->id());
  $this
    ->assertFalse($shipping_method_exists, 'The new shipping method has been deleted from the database using UI.');
}