You are here

static function Generate::createPaymentLineItems in Payment 8.2

Creates payment line items.

Return value

\Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface[]

7 calls to Generate::createPaymentLineItems()
Generate::createPayment in src/Tests/Generate.php
Creates a payment.
PaymentFormWebTest::assertFieldValue in modules/payment_form/tests/src/Functional/Plugin/Field/FieldType/PaymentFormWebTest.php
Asserts a correct field value.
PaymentFormWebTest::setUp in modules/payment_form/tests/src/Functional/Plugin/Field/FieldFormatter/PaymentFormWebTest.php
{@inheritdoc
PaymentFormWebTest::testField in modules/payment_form/tests/src/Functional/Plugin/Field/FieldType/PaymentFormWebTest.php
Tests the field.
PaymentLineItemElement::buildForm in modules/payment_test/src/PaymentLineItemElement.php
Form constructor.

... See full list

File

src/Tests/Generate.php, line 68

Class

Generate
Provides utility tools to support tests.

Namespace

Drupal\payment\Tests

Code

static function createPaymentLineItems() {
  $line_item_manager = Payment::lineItemManager();

  /** @var \Drupal\currency\ConfigImporterInterface $config_importer */
  $config_importer = \Drupal::service('currency.config_importer');
  $config_importer
    ->importCurrency('NLG');
  $config_importer
    ->importCurrency('JPY');
  $config_importer
    ->importCurrency('MGA');
  $line_items = array(
    $line_item_manager
      ->createInstance('payment_basic', [])
      ->setName('foo')
      ->setAmount(9.9)
      ->setCurrencyCode('NLG')
      ->setDescription(static::getRandom()
      ->string()),
    $line_item_manager
      ->createInstance('payment_basic', [])
      ->setName('bar')
      ->setAmount(5.5)
      ->setCurrencyCode('JPY')
      ->setQuantity(2)
      ->setDescription(static::getRandom()
      ->string()),
    $line_item_manager
      ->createInstance('payment_basic', [])
      ->setName('baz')
      ->setAmount(1.1)
      ->setCurrencyCode('MGA')
      ->setQuantity(3)
      ->setDescription(static::getRandom()
      ->string()),
  );
  return $line_items;
}