You are here

private function ContributionPayLaterTest::changeTypeOfAmountElement in Webform CiviCRM Integration 8.5

Change contribution amount widget to radio or checkbox.

1 call to ContributionPayLaterTest::changeTypeOfAmountElement()
ContributionPayLaterTest::testSubmitContribution in tests/src/FunctionalJavascript/ContributionPayLaterTest.php

File

tests/src/FunctionalJavascript/ContributionPayLaterTest.php, line 188

Class

ContributionPayLaterTest
Tests submitting a Webform with CiviCRM: Contribution with Pay later

Namespace

Drupal\Tests\webform_civicrm\FunctionalJavascript

Code

private function changeTypeOfAmountElement($type) {
  $webform = Webform::load('civicrm_webform_test');
  $elements = $webform
    ->getElementsInitialized();
  $elements['contribution_pagebreak']['civicrm_1_contribution_1_contribution_total_amount']['#type'] = $type;
  $elements['contribution_pagebreak']['civicrm_1_contribution_1_contribution_total_amount']['#webform_plugin_id'] = $type;
  $elements['contribution_pagebreak']['civicrm_1_contribution_1_contribution_total_amount']['#options'] = [
    10 => 10,
    20 => 20,
    30 => 30,
  ];
  $webform
    ->setElements($elements);
  $webform
    ->save();
}