You are here

public function PurchasedEntityConstraintValidatorTest::testValidateOrderItemWithoutPurchasedEntity in Commerce Core 8.2

Tests the constraint does not affect non-purchasable entity order items.

@covers ::validate

File

modules/order/tests/src/Kernel/PurchasedEntityConstraintValidatorTest.php, line 84

Class

PurchasedEntityConstraintValidatorTest
Tests the purchased entity constraint on order items.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function testValidateOrderItemWithoutPurchasedEntity() {
  $order = Order::create([
    'type' => 'default',
    'state' => 'draft',
    'store_id' => $this->store,
  ]);
  $order_item = OrderItem::create([
    'type' => 'test',
    'title' => 'Test order item',
    'order_id' => $order,
    'quantity' => '1',
    'unit_price' => new Price('10.00', 'USD'),
  ]);
  $constraints = $order_item
    ->validate();
  $this
    ->assertCount(0, $constraints);
}