You are here

public function PackageTypeTest::testPackageTypeDeletion in Commerce Shipping 8.2

Tests deleting a package type.

File

tests/src/Functional/PackageTypeTest.php, line 109

Class

PackageTypeTest
Tests the package type UI.

Namespace

Drupal\Tests\commerce_shipping\Functional

Code

public function testPackageTypeDeletion() {
  $package_type = $this
    ->createEntity('commerce_package_type', [
    'id' => 'for_deletion',
    'label' => 'For deletion',
    'dimensions' => [
      'length' => '15',
      'width' => '15',
      'height' => '15',
      'unit' => 'm',
    ],
    'weight' => [
      'number' => 0,
      'unit' => 'g',
    ],
  ]);
  $this
    ->drupalGet('admin/commerce/config/package-types/manage/' . $package_type
    ->id() . '/delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->assertSession()
    ->addressEquals('admin/commerce/config/package-types');
  $package_type_exists = (bool) PackageType::load('for_deletion');
  $this
    ->assertFalse($package_type_exists, 'The package type has been deleted from the database.');
}