public function ConfigurationFormTest::testCreateAcceptJsGateway in Commerce Authorize.Net 8
Tests creating an Accept.JS payment gateway.
File
- tests/
src/ FunctionalJavascript/ ConfigurationFormTest.php, line 35
Class
- ConfigurationFormTest
- Tests the Authorize.net payment configuration form.
Namespace
Drupal\Tests\commerce_authnet\FunctionalJavascriptCode
public function testCreateAcceptJsGateway() {
$this
->drupalGet('admin/commerce/config/payment-gateways');
$this
->getSession()
->getPage()
->clickLink('Add payment gateway');
$this
->assertSession()
->addressEquals('admin/commerce/config/payment-gateways/add');
$this
->saveHtmlOutput();
$radio_button = $this
->getSession()
->getPage()
->findField('Authorize.net (Accept.js)');
$radio_button
->click();
$this
->assertSession()
->assertWaitOnAjaxRequest();
// Populate the label / machine name first.
$this
->getSession()
->getPage()
->fillField('label', 'Authorize.net AcceptJS');
$this
->assertJsCondition('jQuery(".machine-name-value:visible").length > 0');
$values = [
'configuration[authorizenet_acceptjs][api_login]' => '64EZ77a2w8',
'configuration[authorizenet_acceptjs][transaction_key]' => '2rrbVvBR6949En2d',
'configuration[authorizenet_acceptjs][client_key]' => '2fejMFQEzA2cg6C5wV3Kz398S94XkPbS56RU2Zq2tfjcmDhDVp8h8XmZ49JQLbY6',
'configuration[authorizenet_acceptjs][mode]' => 'test',
'status' => TRUE,
];
$this
->submitForm($values, 'Save');
$this
->assertSession()
->pageTextContains('Saved the Authorize.net AcceptJS payment gateway.');
$payment_gateway = PaymentGateway::load('authorize_net_acceptjs');
$this
->assertEquals('authorize_net_acceptjs', $payment_gateway
->id());
$this
->assertEquals('Authorize.net AcceptJS', $payment_gateway
->label());
$this
->assertEquals('authorizenet_acceptjs', $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']);
}