You are here

public function RecurringOrderManagerTest::testCloseOrderAlreadyCanceledDoesntAddExtraPayment in Commerce Recurring Framework 8

@covers ::closeOrder

File

tests/src/Kernel/RecurringOrderManagerTest.php, line 369

Class

RecurringOrderManagerTest
@coversDefaultClass \Drupal\commerce_recurring\RecurringOrderManager @group commerce_recurring

Namespace

Drupal\Tests\commerce_recurring\Kernel

Code

public function testCloseOrderAlreadyCanceledDoesntAddExtraPayment() {
  $order = $this->recurringOrderManager
    ->startRecurring($this->activeSubscription);

  // We set the order as canceled.
  $order
    ->set('state', 'canceled')
    ->save();
  $order = $this
    ->reloadEntity($order);
  $this
    ->assertEquals('canceled', $order
    ->getState()
    ->getId());

  // We close an order that was canceled.
  $this->recurringOrderManager
    ->closeOrder($order);
  $order = $this
    ->reloadEntity($order);
  $this
    ->assertFalse($order
    ->isPaid());
  $this
    ->assertEquals('canceled', $order
    ->getState()
    ->getId());

  /** @var \Drupal\commerce_payment\PaymentStorageInterface $payment_storage */
  $payment_storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('commerce_payment');

  // No extra payment has been added.
  $payments = $payment_storage
    ->loadMultipleByOrder($order);
  $this
    ->assertCount(0, $payments);
}