You are here

protected function PaymentTest::setUp in Commerce Core 8.2

Overrides OrderKernelTestBase::setUp

File

modules/payment/tests/src/Kernel/Entity/PaymentTest.php, line 50

Class

PaymentTest
Tests the payment entity.

Namespace

Drupal\Tests\commerce_payment\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_payment');
  $this
    ->installConfig('commerce_payment');
  PaymentGateway::create([
    'id' => 'example',
    'label' => 'Example',
    'plugin' => 'example_onsite',
  ])
    ->save();
  $user = $this
    ->createUser();
  $this->user = $this
    ->reloadEntity($user);
  $order_item = OrderItem::create([
    'title' => 'Membership subscription',
    'type' => 'test',
    'quantity' => 1,
    'unit_price' => [
      'number' => '30.00',
      'currency_code' => 'USD',
    ],
  ]);
  $order_item
    ->save();
  $order = Order::create([
    'type' => 'default',
    'uid' => $this->user
      ->id(),
    'store_id' => $this->store
      ->id(),
    'order_items' => [
      $order_item,
    ],
  ]);
  $order
    ->save();
  $this->order = $this
    ->reloadEntity($order);
}