You are here

public function OrderPaidSubscriberTest::testOnsiteGateway in Commerce Core 8.2

Confirms that on-site payments do not affect the order status.

File

modules/payment/tests/src/Kernel/OrderPaidSubscriberTest.php, line 67

Class

OrderPaidSubscriberTest
Tests the OrderPaidSubscriber.

Namespace

Drupal\Tests\commerce_payment\Kernel

Code

public function testOnsiteGateway() {

  /** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $onsite_gateway */
  $onsite_gateway = PaymentGateway::create([
    'id' => 'onsite',
    'label' => 'On-site',
    'plugin' => 'example_onsite',
    'configuration' => [
      'api_key' => '2342fewfsfs',
      'payment_method_types' => [
        'credit_card',
      ],
    ],
  ]);
  $onsite_gateway
    ->save();
  $this->order
    ->set('payment_gateway', $onsite_gateway);
  $this->order
    ->save();
  $payment = Payment::create([
    'type' => 'payment_default',
    'payment_gateway' => $onsite_gateway
      ->id(),
    'order_id' => $this->order
      ->id(),
    'amount' => $this->order
      ->getTotalPrice(),
    'state' => 'completed',
  ]);
  $payment
    ->save();
  $this->order
    ->save();
  $this
    ->assertEquals('draft', $this->order
    ->getState()
    ->getId());
  $this
    ->assertEmpty($this->order
    ->getOrderNumber());
  $this
    ->assertEmpty($this->order
    ->getPlacedTime());
  $this
    ->assertEmpty($this->order
    ->getCompletedTime());
}