You are here

public function UpgradeConfigTest::testPreAcceptJsUpgrade in Commerce Authorize.Net 8

Tests upgrading from c65e90993f8b4919ed427043ace4e960202092e0.

File

tests/src/Kernel/UpgradeConfigTest.php, line 30

Class

UpgradeConfigTest
Tests config upgrades / post updates.

Namespace

Drupal\Tests\commerce_authnet\Kernel

Code

public function testPreAcceptJsUpgrade() {
  $this
    ->installFixture(__DIR__ . '/../../fixtures/authorizenet-pre-acceptjs.php.gz');
  $gateways = PaymentGateway::loadMultiple();
  $this
    ->assertCount(1, $gateways);
  $authnet_post_updates = $this->container
    ->get('update.post_update_registry')
    ->getModuleUpdateFunctions('commerce_authnet');
  $this
    ->assertCount(2, $authnet_post_updates);
  foreach ($authnet_post_updates as $authnet_post_update) {
    $sandbox = [];
    $authnet_post_update($sandbox);
  }

  /** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */
  $gateway = PaymentGateway::load('authorizenet_pre_acceptjs');
  $this
    ->assertNotNull($gateway);
  $this
    ->assertEquals('authorizenet_acceptjs', $gateway
    ->getPluginId());
  $gateway_configuration = $gateway
    ->getPluginConfiguration();
  $this
    ->assertEquals([
    'mode' => 'test',
    'api_login' => 'TESTING_WITH_FAKE_LOGIN_ID',
    'transaction_key' => 'TESTING_WITH_FAKE_TRANSACTION_KEY',
    'client_key' => '',
    'display_label' => 'Authorize.net',
    'payment_method_types' => [
      'credit_card',
    ],
    'cca_status' => FALSE,
    'cca_api_id' => '',
    'cca_org_unit_id' => '',
    'cca_api_key' => '',
    'collect_billing_information' => TRUE,
  ], $gateway_configuration);
}