You are here

protected function UbercartJavascriptTestBase::createPaymentMethod in Ubercart 8.4

Defines a new payment method.

Parameters

string $plugin_id: The plugin ID of the method.

array $values: (optional) An associative array with possible keys of 'id', and 'label', to initialize the payment method.

Return value

array Array with keys 'id' and 'value', holding the machine name and label of the created payment method.

2 calls to UbercartJavascriptTestBase::createPaymentMethod()
AjaxTest::testCheckoutAjax in uc_store/tests/src/FunctionalJavascript/AjaxTest.php
Tests Ajax on the checkout form.
AjaxTest::testCheckoutPaneAjax in uc_store/tests/src/FunctionalJavascript/AjaxTest.php
Tests Ajax on the checkout panes.

File

uc_store/tests/src/FunctionalJavascript/UbercartJavascriptTestBase.php, line 221

Class

UbercartJavascriptTestBase
Base class for Ubercart PHPUnit browser tests.

Namespace

Drupal\Tests\uc_store\FunctionalJavascript

Code

protected function createPaymentMethod($plugin_id, array $values = []) {
  $has_user = $this->loggedInUser;
  if (!$has_user) {
    $this
      ->drupalLogin($this->adminUser);
  }
  $values += [
    'id' => strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ];
  $this
    ->drupalGet('admin/store/config/payment/add/' . $plugin_id);
  $this
    ->submitForm($values, 'Save');
  if (!$has_user) {
    $this
      ->drupalLogout();
  }
  return $values;
}