mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
refactor: use assertEqualsWithDelta for float comparisons, add @internal to fake()
Replace Assert::assertEquals with Assert::assertEqualsWithDelta (epsilon 0.0001) in assertSubTotal, assertTotal, and assertTotalQuantity to avoid IEEE 754 floating-point equality pitfalls. Add @internal docblock to fake() to signal it is test-only. Add regression test for consecutive withItems calls.
This commit is contained in:
@@ -58,6 +58,14 @@ function makeCartForFactory(): Cart
|
||||
expect(array_unique($ids))->toHaveCount(3);
|
||||
});
|
||||
|
||||
test('consecutive withItems calls produce unique IDs', function () {
|
||||
$this->factory->withItems(2)->withItems(2);
|
||||
|
||||
$ids = $this->cart->getContent()->keys()->toArray();
|
||||
expect(array_unique($ids))->toHaveCount(4);
|
||||
expect($this->cart->getContent()->count())->toBe(4);
|
||||
});
|
||||
|
||||
test('withCoupon adds a coupon condition to the cart', function () {
|
||||
$coupon = new class extends \Wearepixel\Cart\Coupons\Coupon {
|
||||
protected string $code = 'SAVE10';
|
||||
|
||||
Reference in New Issue
Block a user