You are here

protected function UbercartTestBase::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.

1 call to UbercartTestBase::createPaymentMethod()
QuoteTest::setUp in shipping/uc_quote/src/Tests/QuoteTest.php
Sets up a Drupal site for running functional and integration tests.

File

uc_store/src/Tests/UbercartTestBase.php, line 372

Class

UbercartTestBase
Base class for Ubercart Simpletest tests.

Namespace

Drupal\uc_store\Tests

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
    ->drupalPostForm('admin/store/config/payment/add/' . $plugin_id, $values, 'Save');
  if (!$has_user) {
    $this
      ->drupalLogout();
  }
  return $values;
}