toCondition(); expect($condition)->toBeInstanceOf(CartCondition::class); expect($condition->getName())->toBe('GST'); expect($condition->getValue())->toBe('10%'); expect($condition->getType())->toBe('tax'); expect($condition->getTarget())->toBe('subtotal'); }); test('isApplicable() returning false causes toCondition() to throw', function () { expect(fn() => (new NotApplicableTax)->toCondition()) ->toThrow(InvalidTaxRuleException::class); }); test('supports total as target', function () { $tax = new class extends TaxRule { protected string $name = 'Sales Tax'; protected string $value = '8%'; protected string $target = 'total'; public function isApplicable(): bool { return true; } }; expect($tax->toCondition()->getTarget())->toBe('total'); }); test('supports minimum threshold', function () { $tax = new class extends TaxRule { protected string $name = 'Luxury Tax'; protected string $value = '15%'; protected ?float $minimum = 500.0; public function isApplicable(): bool { return true; } }; expect($tax->toCondition()->getMinimum())->toBe(500.0); }); });