You are here

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

Tests creating a Visa Checkout payment gateway.

File

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

Class

ConfigurationFormTest
Tests the Authorize.net payment configuration form.

Namespace

Drupal\Tests\commerce_authnet\FunctionalJavascript

Code

public function testCreateVisaCheckoutGateway() {
  $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 (Visa Checkout)');
  $radio_button
    ->click();
  $this
    ->waitForAjaxToFinish();

  // Populate the label / machine name first.
  $this
    ->getSession()
    ->getPage()
    ->fillField('label', 'Authorize.net Visa Checkout');
  $this
    ->assertJsCondition('jQuery(".machine-name-value:visible").length > 0');
  $values = [
    'configuration[authorizenet_visa_checkout][api_login]' => '64EZ77a2w8',
    'configuration[authorizenet_visa_checkout][transaction_key]' => '2rrbVvBR6949En2d',
    'configuration[authorizenet_visa_checkout][client_key]' => '2fejMFQEzA2cg6C5wV3Kz398S94XkPbS56RU2Zq2tfjcmDhDVp8h8XmZ49JQLbY6',
    'configuration[authorizenet_visa_checkout][visa_checkout_api_key]' => 'I3IW0JTMU1JOIY90KBT721-L5zdL2VQ7GQ6tPA-xvjmOLO-Xo',
    'configuration[authorizenet_visa_checkout][mode]' => 'test',
    'status' => 1,
  ];
  $this
    ->submitForm($values, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Authorize.net Visa Checkout payment gateway.');
  $payment_gateway = PaymentGateway::load('authorize_net_visa_checkout');
  $this
    ->assertEquals('authorize_net_visa_checkout', $payment_gateway
    ->id());
  $this
    ->assertEquals('Authorize.net Visa Checkout', $payment_gateway
    ->label());
  $this
    ->assertEquals('authorizenet_visa_checkout', $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']);
}