You are here

protected function ManualPaymentAdminTest::setUp in Commerce Core 8.2

Overrides CommerceBrowserTestBase::setUp

File

modules/payment/tests/src/Functional/ManualPaymentAdminTest.php, line 62

Class

ManualPaymentAdminTest
Tests the admin UI for payments of type 'payment_manual'.

Namespace

Drupal\Tests\commerce_payment\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $this->paymentGateway = $this
    ->createEntity('commerce_payment_gateway', [
    'id' => 'manual',
    'label' => 'Manual example',
    'plugin' => 'manual',
  ]);
  $this->paymentGateway
    ->setPluginConfiguration([
    'display_label' => 'Cash on delivery',
    'instructions' => [
      'value' => 'Test instructions.',
      'format' => 'plain_text',
    ],
  ]);
  $this->paymentGateway
    ->save();

  // An order item type that doesn't need a purchasable entity, for simplicity.
  OrderItemType::create([
    'id' => 'test',
    'label' => 'Test',
    'orderType' => 'default',
  ])
    ->save();
  $order_item = $this
    ->createEntity('commerce_order_item', [
    'type' => 'test',
    'quantity' => 1,
    'unit_price' => new Price('10', 'USD'),
  ]);
  $this->order = $this
    ->createEntity('commerce_order', [
    'uid' => $this->loggedInUser
      ->id(),
    'type' => 'default',
    'state' => 'draft',
    'order_items' => [
      $order_item,
    ],
    'store_id' => $this->store,
  ]);
  $this->paymentUri = Url::fromRoute('entity.commerce_payment.collection', [
    'commerce_order' => $this->order
      ->id(),
  ])
    ->toString();
}