public function CartManagerTest::testAddOrderItem in Commerce Core 8.2
Tests that order items without purchasable entities do not cause crashes.
File
- modules/
cart/ tests/ src/ Kernel/ CartManagerTest.php, line 138
Class
- CartManagerTest
- Tests the cart manager.
Namespace
Drupal\Tests\commerce_cart\KernelCode
public function testAddOrderItem() {
$cart = $this->cartProvider
->createCart('default', $this->store, $this->user);
$order_item = OrderItem::create([
'type' => 'default',
'quantity' => 2,
'unit_price' => new Price('12.00', 'USD'),
]);
$order_item
->save();
$this->cartManager
->addOrderItem($cart, $order_item);
$this
->assertEquals(1, count($cart
->getItems()));
}