Commit 0e2be938 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher Committed by Sascha Grossenbacher
Browse files

Issue #3317005 by Berdir: Drupal 10 compatibility

parent 138a6486
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
  },
  "require" : {
    "ext-bcmath": "*",
    "drupal/core": "^9.3 || ^10",
    "drupal/currency": "~3.0",
    "drupal/plugin": "~2.2"
  }
+1 −1
Original line number Diff line number Diff line
name: Payment Form Field
description: Provides a field to add payment forms to entities.
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^9.3 || ^10
configure: payment.payment_type
configure_parameters:
  bundle: payment_form
+6 −7
Original line number Diff line number Diff line
@@ -114,11 +114,12 @@ class PaymentFormWebTest extends BrowserTestBase {
   */
  public function testFormatter() {
    // Make sure there are no payments yet.
    $this->assertEqual(count($this->paymentStorage->loadMultiple()), 0);
    $this->assertEquals(0, count($this->paymentStorage->loadMultiple()));
    $user = $this->drupalCreateUser(['access user profiles']);
    $this->drupalLogin($user);
    $path = 'user/' . $this->user->id();
    $this->drupalPostForm($path, [], t('Pay'));
    $this->drupalGet($path);
    $this->submitForm([], t('Pay'));
    // The front page is the currently logged-in user.
    // @todo The following code does not work, as it results in the following
    // failure if this test is run on Drush' built-in server:
@@ -135,14 +136,12 @@ class PaymentFormWebTest extends BrowserTestBase {
    // $this->assertUrl($path);
    // @endcode

    $this->assertResponse('200');
    $this->assertSession()->statusCodeEquals('200');
    // This is supposed to be the first and only payment.
    /** @var \Drupal\payment\Entity\PaymentInterface $payment */
    $payment = $this->paymentStorage->load(1);
    if ($this->assertTrue((bool) $payment)) {
    $this->assertTrue($payment->getPaymentType() instanceof PaymentForm);
      $this->assertIdentical($payment->getPaymentStatus()->getPluginId(), $this->executeStatusPluginId);
    }
    $this->assertSame($payment->getPaymentStatus()->getPluginId(), $this->executeStatusPluginId);
  }

}
+12 −10
Original line number Diff line number Diff line
@@ -34,14 +34,15 @@ class PaymentFormWebTest extends BrowserTestBase {

    // Test the widget when setting a default field value.
    $field_name = strtolower($this->randomMachineName());
    $this->drupalPostForm('admin/config/people/accounts/fields/add-field', [
    $this->drupalGet('admin/config/people/accounts/fields/add-field');
    $this->submitForm([
      'label' => $this->randomString(),
      'field_name' => $field_name,
      'new_storage_type' => 'payment_form',
    ], t('Save and continue'));
    $this->drupalPostForm(NULL, [], t('Save field settings'));
    $this->drupalPostForm(NULL, [], t('Add and configure a new line item'));
    $this->drupalPostForm(NULL, [
    $this->submitForm([], t('Save field settings'));
    $this->submitForm([], t('Add and configure a new line item'));
    $this->submitForm([
      'default_value_input[field_' . $field_name . '][line_items][line_items][payment_basic][plugin_form][description]' => $this->randomString(),
    ], t('Save settings'));
    // Get all payment_form fields.
@@ -51,11 +52,12 @@ class PaymentFormWebTest extends BrowserTestBase {
    $this->assertTrue(in_array('user.field_' . $field_name, $field_names));

    // Test the widget when creating an entity.
    $this->drupalPostForm('user/' . $user->id() . '/edit', [
    $this->drupalGet('user/' . $user->id() . '/edit');
    $this->submitForm([
      'field_' . $field_name . '[line_items][add_more][type]' => 'payment_basic',
    ], t('Add and configure a new line item'));
    $description = $this->randomString();
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][amount]' => '9,87',
      'field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][currency_code]' => 'EUR',
      'field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][description]' => $description,
@@ -64,10 +66,10 @@ class PaymentFormWebTest extends BrowserTestBase {

    // Test whether the widget displays field values.
    $this->drupalGet('user/' . $user->id() . '/edit');
    $this->assertFieldByName('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][amount]', '9.87');
    $this->assertFieldByName('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][currency_code]', 'EUR');
    $this->assertFieldByName('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][description]', $description);
    $this->assertFieldByName('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][quantity]', 37);
    $this->assertSession()->fieldValueEquals('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][amount]', '9.87');
    $this->assertSession()->fieldValueEquals('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][amount][currency_code]', 'EUR');
    $this->assertSession()->fieldValueEquals('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][description]', $description);
    $this->assertSession()->fieldValueEquals('field_' . $field_name . '[line_items][line_items][payment_basic][plugin_form][quantity]', 37);
  }

}
+1 −1
Original line number Diff line number Diff line
name: Payment Reference Field
description: Provides a field to add payment references to entities.
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^9.3 || ^10
configure: payment.payment_type
configure_parameters:
  bundle: payment_reference
Loading