You are here

public function CheckoutFlowTest::testCheckoutFlowEditing in Commerce Core 8.2

Tests editing a checkout flow.

File

modules/checkout/tests/src/Functional/CheckoutFlowTest.php, line 53

Class

CheckoutFlowTest
Tests the checkout flow UI.

Namespace

Drupal\Tests\commerce_checkout\Functional

Code

public function testCheckoutFlowEditing() {
  $this
    ->createEntity('commerce_checkout_flow', [
    'label' => 'Test checkout flow',
    'id' => 'test_checkout_flow',
    'plugin' => 'multistep_default',
  ]);
  $this
    ->drupalGet('admin/commerce/config/checkout-flows/manage/test_checkout_flow');
  $edit = [
    'label' => 'Name has changed',
    'configuration[panes][billing_information][weight]' => 1,
    'configuration[panes][contact_information][weight]' => 2,
    'configuration[panes][review][step_id]' => '_disabled',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains(t('Saved the @name checkout flow.', [
    '@name' => $edit['label'],
  ]));
  $checkout_flow = CheckoutFlow::load('test_checkout_flow');
  $this
    ->assertEquals('Name has changed', $checkout_flow
    ->label());
  $this
    ->assertEquals(1, $checkout_flow
    ->get('configuration')['panes']['billing_information']['weight']);
  $this
    ->assertEquals(2, $checkout_flow
    ->get('configuration')['panes']['contact_information']['weight']);
  $this
    ->assertEquals('_disabled', $checkout_flow
    ->get('configuration')['panes']['review']['step']);
}