You are here

protected function PaymentAccessTest::setUp in Commerce Core 8.2

Overrides OrderKernelTestBase::setUp

File

modules/payment/tests/src/Kernel/PaymentAccessTest.php, line 47

Class

PaymentAccessTest
Tests the payment access control.

Namespace

Drupal\Tests\commerce_payment\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_payment_method');
  $this
    ->installEntitySchema('commerce_payment');
  $this
    ->installConfig([
    'commerce_payment',
  ]);
  $order_item = OrderItem::create([
    'type' => 'test',
    'quantity' => 1,
    'unit_price' => new Price('10', 'USD'),
  ]);
  $order_item
    ->save();
  $this->order = Order::create([
    'type' => 'default',
    'store_id' => $this->store,
    'order_items' => [
      $order_item,
    ],
    'state' => 'draft',
    'payment_gateway' => 'onsite',
  ]);
  $this->order
    ->save();

  // Create uid: 1 here so that it's skipped in test cases.
  $admin_user = $this
    ->createUser();
  $regular_user = $this
    ->createUser([
    'uid' => 2,
  ]);
  \Drupal::currentUser()
    ->setAccount($regular_user);
}