You are here

public function InvoiceTypeTest::testDelete in Commerce Invoice 8.2

Tests deleting an invoice type.

File

tests/src/FunctionalJavascript/InvoiceTypeTest.php, line 94

Class

InvoiceTypeTest
Tests the invoice type UI.

Namespace

Drupal\Tests\commerce_invoice\FunctionalJavascript

Code

public function testDelete() {

  /** @var \Drupal\commerce_invoice\Entity\InvoiceTypeInterface $invoice_type */
  $invoice_type = $this
    ->createEntity('commerce_invoice_type', [
    'id' => 'foo',
    'label' => 'Label for foo',
    'workflow' => 'invoice_default',
  ]);
  $this
    ->drupalGet($invoice_type
    ->toUrl('delete-form'));
  $this
    ->assertSession()
    ->pageTextContains(t('Are you sure you want to delete the invoice type @label?', [
    '@label' => $invoice_type
      ->label(),
  ]));
  $this
    ->assertSession()
    ->pageTextContains(t('This action cannot be undone.'));
  $this
    ->submitForm([], t('Delete'));
  $invoice_type_exists = (bool) InvoiceType::load($invoice_type
    ->id());
  $this
    ->assertEmpty($invoice_type_exists);
}