You are here

public function InvoiceTypeTest::testAdd in Commerce Invoice 8.2

Tests adding an invoice type.

File

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

Class

InvoiceTypeTest
Tests the invoice type UI.

Namespace

Drupal\Tests\commerce_invoice\FunctionalJavascript

Code

public function testAdd() {
  $this
    ->drupalGet('admin/commerce/config/invoice-types/add');
  $edit = [
    'label' => 'Foo',
    'footerText' => $this
      ->randomString(),
    'paymentTerms' => 'payment terms!',
    'dueDays' => 20,
  ];
  $this
    ->getSession()
    ->getPage()
    ->fillField('label', $edit['label']);
  $this
    ->assertJsCondition('jQuery(".machine-name-value:visible").length > 0');
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('Saved the Foo invoice type.');
  $invoice_type = InvoiceType::load('foo');
  $this
    ->assertEquals($edit['footerText'], $invoice_type
    ->getFooterText());
  $this
    ->assertEquals($edit['paymentTerms'], $invoice_type
    ->getPaymentTerms());
  $this
    ->assertEquals($edit['dueDays'], $invoice_type
    ->getDueDays());
  $this
    ->assertNotEmpty($invoice_type);
}