Testing
Cart::fake()
Cart::fake() replaces the active driver with an in-memory NullDriver and returns a CartFactory for seeding test state.
use Wearepixel\Cart\Cart;
// In your test
$factory = app('cart')->fake();
$factory->withItems(3);
$factory->withCondition(new CartCondition(['name' => 'GST', 'type' => 'tax', 'value' => '10%', 'target' => 'subtotal']));
// Or chain it
app('cart')->fake()->withItems(2)->withCondition($condition);
Assertion Methods
After fake(), the Cart instance exposes assertion methods:
$cart = app('cart');
$cart->fake();
$cart->add(1, 'Widget', 50.00, 2);
$cart->assertContains(1); // item exists
$cart->assertCount(1); // 1 distinct item
$cart->assertTotalQuantity(2); // 2 units
$cart->assertSubTotal(100.00); // subtotal
$cart->assertTotal(100.00); // total
$cart->assertNotEmpty(); // cart has items
$cart->assertEmpty(); // cart is empty
$cart->assertConditionApplied('GST'); // condition present