From ac94829f25a58f9e555cbf1c86a0af13e5221e7e Mon Sep 17 00:00:00 2001 From: Joaquin Marcher Date: Wed, 3 May 2017 17:09:57 +0200 Subject: [PATCH 1/2] Update CartOptionsMagicMethodsTrait.php --- src/Traits/CartOptionsMagicMethodsTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/CartOptionsMagicMethodsTrait.php b/src/Traits/CartOptionsMagicMethodsTrait.php index fe2f964..7ecf331 100644 --- a/src/Traits/CartOptionsMagicMethodsTrait.php +++ b/src/Traits/CartOptionsMagicMethodsTrait.php @@ -54,7 +54,7 @@ public function __set($option, $value) } break; case CartItem::ITEM_TAX: - if (!empty($value) && (!is_numeric($value) || $value > 1)) { + if (!empty($value) && (!is_numeric($value))) { throw new InvalidTaxableValue('The tax must be a float less than 1'); } break; From 73973fa285b86507d406565bd1eb7f1d2419200a Mon Sep 17 00:00:00 2001 From: Joaquin Marcher Date: Wed, 3 May 2017 19:06:09 +0200 Subject: [PATCH 2/2] Fixed tests failing --- composer.json | 2 +- src/Traits/CartOptionsMagicMethodsTrait.php | 2 +- tests/MagicFunctionsTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 10851fc..71cca97 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": ">=5.6", - "illuminate/support": "5.*" + "illuminate/support": "5.3" }, "require-dev": { "phpunit/phpunit": "4.*", diff --git a/src/Traits/CartOptionsMagicMethodsTrait.php b/src/Traits/CartOptionsMagicMethodsTrait.php index 7ecf331..18b56f5 100644 --- a/src/Traits/CartOptionsMagicMethodsTrait.php +++ b/src/Traits/CartOptionsMagicMethodsTrait.php @@ -55,7 +55,7 @@ public function __set($option, $value) break; case CartItem::ITEM_TAX: if (!empty($value) && (!is_numeric($value))) { - throw new InvalidTaxableValue('The tax must be a float less than 1'); + throw new InvalidTaxableValue('The tax must be a number'); } break; case CartItem::ITEM_TAXABLE: diff --git a/tests/MagicFunctionsTest.php b/tests/MagicFunctionsTest.php index 493e6f1..6c8c976 100644 --- a/tests/MagicFunctionsTest.php +++ b/tests/MagicFunctionsTest.php @@ -31,10 +31,10 @@ public function testSet() $this->assertEquals(123, $item->test_option); try { - $item->tax = 2; + $item->tax = 'not_a_number'; $this->setExpectedException(InvalidTaxableValue::class); } catch (InvalidTaxableValue $e) { - $this->assertEquals('The tax must be a float less than 1', $e->getMessage()); + $this->assertEquals('The tax must be a number', $e->getMessage()); } try {