You are here

public function OrderTypeTest::testAdd in Commerce Core 8.2

Tests adding an order type.

File

modules/order/tests/src/Functional/OrderTypeTest.php, line 29

Class

OrderTypeTest
Tests the order type UI.

Namespace

Drupal\Tests\commerce_order\Functional

Code

public function testAdd() {

  // Remove the default order type to be able to test creating the
  // order_items field anew.
  OrderType::load('default')
    ->delete();
  $this
    ->drupalGet('admin/commerce/config/order-types/add');
  $edit = [
    'id' => 'foo',
    'label' => 'Foo',
    'refresh_mode' => 'always',
    'refresh_frequency' => 60,
  ];
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('Saved the Foo order type.');
  $order_type = OrderType::load('foo');
  $this
    ->assertNotEmpty($order_type);
  $this
    ->assertEmpty($order_type
    ->getNumberPatternId());
  $this
    ->assertEquals($edit['refresh_mode'], $order_type
    ->getRefreshMode());
  $this
    ->assertEquals($edit['refresh_frequency'], $order_type
    ->getRefreshFrequency());
}