You are here

public function OrderRefreshTest::testAvailabilityOrderRefresh in Commerce Core 8.2

Tests the order refresh, with the availability processor.

File

modules/order/tests/src/Kernel/OrderRefreshTest.php, line 230

Class

OrderRefreshTest
Tests the order refresh process.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function testAvailabilityOrderRefresh() {
  $order_refresh = $this
    ->createOrderRefresh();
  $order_item = $this->orderItemStorage
    ->createFromPurchasableEntity($this->variation1);
  $order_item
    ->save();
  $another_order_item = $this->orderItemStorage
    ->createFromPurchasableEntity($this->variation2);
  $another_order_item
    ->save();
  $this->order
    ->setItems([
    $order_item,
    $another_order_item,
  ]);
  $this->order
    ->setRefreshState(Order::REFRESH_SKIP);
  $this->order
    ->save();
  $this
    ->assertEquals(2, count($this->order
    ->getItems()));
  $order_refresh
    ->refresh($this->order);
  $this
    ->assertEquals(1, count($this->order
    ->getItems()));
}