You are here

public function PaymentGatewayTest::testEdit in Commerce Core 8.2

Tests editing a payment gateway.

File

modules/payment/tests/src/Functional/PaymentGatewayTest.php, line 69

Class

PaymentGatewayTest
Tests the payment gateway UI.

Namespace

Drupal\Tests\commerce_payment\Functional

Code

public function testEdit() {
  $values = [
    'id' => 'edit_example',
    'label' => 'Edit example',
    'plugin' => 'example_offsite_redirect',
    'status' => 0,
  ];
  $payment_gateway = $this
    ->createEntity('commerce_payment_gateway', $values);
  $this
    ->drupalGet($payment_gateway
    ->toUrl('edit-form'));
  $edit = $values + [
    'configuration[example_offsite_redirect][redirect_method]' => 'get',
    'configuration[example_offsite_redirect][mode]' => 'live',
    'conditionOperator' => 'OR',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Edit example payment gateway.');
  \Drupal::entityTypeManager()
    ->getStorage('commerce_payment_gateway')
    ->resetCache();
  $payment_gateway = PaymentGateway::load('edit_example');
  $this
    ->assertEquals('edit_example', $payment_gateway
    ->id());
  $this
    ->assertEquals('Edit example', $payment_gateway
    ->label());
  $this
    ->assertEquals('example_offsite_redirect', $payment_gateway
    ->getPluginId());
  $this
    ->assertEmpty($payment_gateway
    ->getConditions());
  $this
    ->assertEquals('OR', $payment_gateway
    ->getConditionOperator());
  $this
    ->assertEquals(FALSE, $payment_gateway
    ->status());
  $payment_gateway_plugin = $payment_gateway
    ->getPlugin();
  $this
    ->assertEquals('live', $payment_gateway_plugin
    ->getMode());
  $configuration = $payment_gateway_plugin
    ->getConfiguration();
  $this
    ->assertEquals('get', $configuration['redirect_method']);
}