diff --git a/tests/unit/Tax/Helpers/TaxCest.php b/tests/unit/Tax/Helpers/TaxCest.php index 443234d5d..2ed03a977 100644 --- a/tests/unit/Tax/Helpers/TaxCest.php +++ b/tests/unit/Tax/Helpers/TaxCest.php @@ -3,19 +3,22 @@ namespace Tests\Unit\Tax\Helpers; use Cart; +use Illuminate\Support\Facades\Config; use UnitTester; +use Webkul\Tax\Models\TaxCategory; use Webkul\Tax\Models\TaxMap; use Webkul\Tax\Models\TaxRate; -use Webkul\Tax\Models\TaxCategory; -use Illuminate\Support\Facades\Config; class TaxCest { public $scenario; private const PRODUCT1_QTY = 11; + private const PRODUCT2_QTY = 7; + private const TAX_RATE_PRECISION = 4; + private const CART_TOTAL_PRECISION = 2; public function _before(UnitTester $I) @@ -72,27 +75,26 @@ class TaxCest 'quantity' => self::PRODUCT2_QTY, ]); - // rounded by precision of 2 because this are sums of corresponding tax categories + // rounded by precision of 2 because these are sums of corresponding tax categories $expectedTaxAmount1 = round( round(self::PRODUCT1_QTY * $product1->price, self::CART_TOTAL_PRECISION) - * $tax1->tax_rate / 100, + * $tax1->tax_rate / 100, self::CART_TOTAL_PRECISION ); $expectedTaxAmount2 = round( round(self::PRODUCT2_QTY * $product2->price, self::CART_TOTAL_PRECISION) - * $tax2->tax_rate / 100, + * $tax2->tax_rate / 100, self::CART_TOTAL_PRECISION ); $this->scenario = [ 'cart' => Cart::getCart(), 'expectedTaxRates' => [ - (string)round((float)$tax1->tax_rate, 4) => $expectedTaxAmount1, - (string)round((float)$tax2->tax_rate, 4) => $expectedTaxAmount2, + (string) round((float) $tax1->tax_rate, self::TAX_RATE_PRECISION) => $expectedTaxAmount1, + (string) round((float) $tax2->tax_rate, self::TAX_RATE_PRECISION) => $expectedTaxAmount2, ], - 'expectedTaxTotal' => - round($expectedTaxAmount1 + $expectedTaxAmount2, self::CART_TOTAL_PRECISION), + 'expectedTaxTotal' => round($expectedTaxAmount1 + $expectedTaxAmount2, self::CART_TOTAL_PRECISION), ]; }