You are here

public function SermepaGatewayUiTest::testSermepaGatewayEditing in Commerce sermepa 8.2

Tests editing a Sermepa payment gateway.

File

tests/src/FunctionalJavascript/SermepaGatewayUiTest.php, line 90

Class

SermepaGatewayUiTest
Tests the payment gateway UI for 'Sermepa' case.

Namespace

Drupal\Tests\commerce_sermepa\FunctionalJavascript

Code

public function testSermepaGatewayEditing() {
  $values = [
    'id' => 'edit_sermepa',
    'label' => 'Edit sermepa',
    'plugin' => 'commerce_sermepa',
    'status' => 1,
  ];
  $payment_gateway = $this
    ->createEntity('commerce_payment_gateway', $values);
  $this
    ->drupalGet('admin/commerce/config/payment-gateways/manage/' . $payment_gateway
    ->id());
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][mode]')
    ->setValue('test');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_name]')
    ->setValue('Merchant name');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_code]')
    ->setValue('000000001');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_group]')
    ->setValue('MG');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_password]')
    ->setValue('00000000000000000000000000000000');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_terminal]')
    ->setValue('001');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_paymethods][]')
    ->setValue([
    'D',
  ]);
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][merchant_consumer_language]')
    ->setValue('001');
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][currency]')
    ->setValue(840);
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][transaction_type]')
    ->setValue(0);
  $this
    ->assertSession()
    ->fieldExists('configuration[commerce_sermepa][instructions][value]')
    ->setValue('Instructions');
  $this
    ->assertSession()
    ->buttonExists('Save')
    ->click();

  // Wait for the payment gateways collection page.
  $this
    ->assertSession()
    ->waitForElementVisible('css', '.commerce-payment-gateways');
  $this
    ->assertSession()
    ->addressEquals('admin/commerce/config/payment-gateways');
  $this
    ->assertSession()
    ->responseContains('Edit sermepa');
  $payment_gateway = $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_payment_gateway')
    ->load('edit_sermepa');
  $this
    ->assertEquals('edit_sermepa', $payment_gateway
    ->id());
  $this
    ->assertEquals('Edit sermepa', $payment_gateway
    ->label());
  $this
    ->assertEquals('commerce_sermepa', $payment_gateway
    ->getPluginId());
  $payment_gateway_plugin = $payment_gateway
    ->getPlugin();
  $this
    ->assertEquals('test', $payment_gateway_plugin
    ->getMode());
  $configuration = $payment_gateway_plugin
    ->getConfiguration();
  $this
    ->assertEquals('Merchant name', $configuration['merchant_name']);
  $this
    ->assertEquals('000000001', $configuration['merchant_code']);
  $this
    ->assertEquals('MG', $configuration['merchant_group']);
  $this
    ->assertEquals('00000000000000000000000000000000', $configuration['merchant_password']);
  $this
    ->assertEquals('001', $configuration['merchant_terminal']);
  $this
    ->assertEquals([
    'D' => 'D',
  ], $configuration['merchant_paymethods']);
  $this
    ->assertEquals('001', $configuration['merchant_consumer_language']);
  $this
    ->assertEquals(840, $configuration['currency']);
  $this
    ->assertEquals(0, $configuration['transaction_type']);
  $this
    ->assertEquals('Instructions', $configuration['instructions']['value']);
  $this
    ->assertEquals('plain_text', $configuration['instructions']['format']);
}