You are here

protected function PurchaseOrderTest::setUp in Commerce Purchase Order 8

Overrides CommerceBrowserTestBase::setUp

File

tests/src/Functional/PurchaseOrderTest.php, line 67

Class

PurchaseOrderTest
Tests the checkout of an order.

Namespace

Drupal\Tests\commerce_purchase_order\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->store
    ->set('billing_countries', [
    'US',
  ]);
  $this->store
    ->save();

  /** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
  $payment_gateway = PaymentGateway::create([
    'id' => 'po',
    'label' => 'PO',
    'plugin' => 'purchase_order_gateway',
    'configuration' => [
      'limit_open' => 3,
      'user_approval' => 0,
      'instructions' => [
        'value' => 'Sample payment instructions.',
        'format' => 'plain_text',
      ],
    ],
  ]);
  $payment_gateway
    ->save();
  $variation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => 9.99,
      'currency_code' => 'USD',
    ],
  ]);

  /** @var \Drupal\commerce_product\Entity\ProductInterface $product */
  $this->product = $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => 'My product',
    'variations' => [
      $variation,
    ],
    'stores' => [
      $this->store,
    ],
  ]);
  $this
    ->placeBlock('commerce_cart');
  $this
    ->placeBlock('commerce_checkout_progress');
}