You are here

public function ConfigurationFormTest::testCreateEcheckGateway in Commerce Authorize.Net 8

Tests creating an ECheck payment gateway.

File

tests/src/FunctionalJavascript/ConfigurationFormTest.php, line 71

Class

ConfigurationFormTest
Tests the Authorize.net payment configuration form.

Namespace

Drupal\Tests\commerce_authnet\FunctionalJavascript

Code

public function testCreateEcheckGateway() {
  $this
    ->drupalGet('admin/commerce/config/payment-gateways');
  $this
    ->getSession()
    ->getPage()
    ->clickLink('Add payment gateway');
  $this
    ->assertSession()
    ->addressEquals('admin/commerce/config/payment-gateways/add');
  $radio_button = $this
    ->getSession()
    ->getPage()
    ->findField('Authorize.net (Echeck)');
  $radio_button
    ->click();
  $this
    ->waitForAjaxToFinish();

  // Populate the label / machine name first.
  $this
    ->getSession()
    ->getPage()
    ->fillField('label', 'Authorize.net Echeck');
  $this
    ->assertJsCondition('jQuery(".machine-name-value:visible").length > 0');
  $values = [
    'configuration[authorizenet_echeck][api_login]' => '64EZ77a2w8',
    'configuration[authorizenet_echeck][transaction_key]' => '2rrbVvBR6949En2d',
    'configuration[authorizenet_echeck][client_key]' => '2fejMFQEzA2cg6C5wV3Kz398S94XkPbS56RU2Zq2tfjcmDhDVp8h8XmZ49JQLbY6',
    'configuration[authorizenet_echeck][mode]' => 'test',
    'status' => 1,
  ];
  $this
    ->submitForm($values, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Authorize.net Echeck payment gateway.');
  $payment_gateway = PaymentGateway::load('authorize_net_echeck');
  $this
    ->assertEquals('authorize_net_echeck', $payment_gateway
    ->id());
  $this
    ->assertEquals('Authorize.net Echeck', $payment_gateway
    ->label());
  $this
    ->assertEquals('authorizenet_echeck', $payment_gateway
    ->getPluginId());
  $this
    ->assertEquals(TRUE, $payment_gateway
    ->status());
  $payment_gateway_plugin = $payment_gateway
    ->getPlugin();
  $this
    ->assertEquals('test', $payment_gateway_plugin
    ->getMode());
  $config = $payment_gateway_plugin
    ->getConfiguration();
  $this
    ->assertEquals('64EZ77a2w8', $config['api_login']);
  $this
    ->assertEquals('2rrbVvBR6949En2d', $config['transaction_key']);
  $this
    ->assertEquals('2fejMFQEzA2cg6C5wV3Kz398S94XkPbS56RU2Zq2tfjcmDhDVp8h8XmZ49JQLbY6', $config['client_key']);
}