You are here

protected function OffsiteOrderDataTest::setUp in Commerce Core 8.2

Overrides CommerceWebDriverTestBase::setUp

File

modules/payment/tests/src/FunctionalJavascript/OffsiteOrderDataTest.php, line 42

Class

OffsiteOrderDataTest
Tests saving order data before and after saving the payment.

Namespace

Drupal\Tests\commerce_payment\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  $variation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => strtolower($this
      ->randomMachineName()),
    'price' => [
      'number' => '39.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,
    ],
  ]);

  /** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
  $payment_gateway = PaymentGateway::create([
    'id' => 'offsite',
    'label' => 'Off-site',
    'plugin' => 'test_offsite',
    'configuration' => [
      // PayPal uses GET, follow its pattern for this test.
      'redirect_method' => 'get',
      'payment_method_types' => [
        'credit_card',
      ],
    ],
  ]);
  $payment_gateway
    ->save();
}