From 5fbfb80a18eb0e44d99b1a9c6af04ce2ea42e00e Mon Sep 17 00:00:00 2001 From: Bastien Tafforeau Date: Fri, 24 Nov 2023 16:45:37 +0100 Subject: [PATCH] Fixing CI issues --- src/Category/Category.php | 26 +++++++++++++-- src/Discount/Discount.php | 18 +--------- src/Product/Exception/ProductException.php | 1 - src/Product/Product.php | 6 ++-- tests/Unit/Amount/AmountTest.php | 38 +++++++++++----------- tests/Unit/Discount/DiscountTest.php | 35 +++++++------------- 6 files changed, 58 insertions(+), 66 deletions(-) diff --git a/src/Category/Category.php b/src/Category/Category.php index 87c2620a4..c530e93c5 100644 --- a/src/Category/Category.php +++ b/src/Category/Category.php @@ -1,8 +1,28 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PrestashopCheckout\Category; class Category { - const DIGITAL_GOODS = "DIGITAL_GOODS"; - const PHYSICAL_GOODS = "PHYSICAL_GOODS"; - const DONATION = "DONATION"; + const DIGITAL_GOODS = 'DIGITAL_GOODS'; + const PHYSICAL_GOODS = 'PHYSICAL_GOODS'; + const DONATION = 'DONATION'; } diff --git a/src/Discount/Discount.php b/src/Discount/Discount.php index d6278a52a..b80e3dcee 100644 --- a/src/Discount/Discount.php +++ b/src/Discount/Discount.php @@ -38,7 +38,7 @@ class Discount */ public function __construct($name, $value) { - $this->name = $this->assertDiscountNameIsValid($name); + $this->name = $name; $this->value = $this->assertDiscountValueIsValid($value); } @@ -58,22 +58,6 @@ public function getValue() return $this->value; } - /** - * @param string $name - * - * @return string - * - * @throws DiscountException - */ - public function assertDiscountNameIsValid($name) - { - if (is_string($name)) { - return $name; - } - - throw new DiscountException('Discount name is not a string', DiscountException::INVALID_NAME); - } - /** * @param string $value * diff --git a/src/Product/Exception/ProductException.php b/src/Product/Exception/ProductException.php index 44b0edc87..c83e2188b 100644 --- a/src/Product/Exception/ProductException.php +++ b/src/Product/Exception/ProductException.php @@ -24,5 +24,4 @@ class ProductException extends PsCheckoutException { - } diff --git a/src/Product/Product.php b/src/Product/Product.php index 1136e445c..1dadc9ed6 100644 --- a/src/Product/Product.php +++ b/src/Product/Product.php @@ -33,10 +33,10 @@ class Product /** @var int */ private $quantity; - /** @var boolean */ + /** @var bool */ private $isInStock; - /** @var boolean */ + /** @var bool */ private $isAvailableForOrder; /** @var string */ @@ -77,7 +77,7 @@ public function getUnitPrice() } /** - * @return string + * @return int */ public function getQuantity() { diff --git a/tests/Unit/Amount/AmountTest.php b/tests/Unit/Amount/AmountTest.php index de13fe8b3..e20620a63 100644 --- a/tests/Unit/Amount/AmountTest.php +++ b/tests/Unit/Amount/AmountTest.php @@ -39,21 +39,21 @@ public function validAmountDataProvider() [ [ 'value' => '24.99', - 'currencyCode' => 'EUR' + 'currencyCode' => 'EUR', ], ], [ [ 'value' => '25.00', - 'currencyCode' => 'USD' - ] + 'currencyCode' => 'USD', + ], ], [ [ 'value' => '17', - 'currencyCode' => 'JPY' - ] - ] + 'currencyCode' => 'JPY', + ], + ], ]; } @@ -63,47 +63,47 @@ public function invalidAmountDataProvider() [ [ 'value' => 'twenty', - 'currencyCode' => 'EUR' + 'currencyCode' => 'EUR', ], [ 'class' => AmountException::class, 'code' => AmountException::INVALID_AMOUNT, - 'message' => 'Amount value twenty is not a numeric' - ] + 'message' => 'Amount value twenty is not a numeric', + ], ], [ [ 'value' => '23..66', - 'currencyCode' => 'USD' + 'currencyCode' => 'USD', ], [ 'class' => AmountException::class, 'code' => AmountException::INVALID_AMOUNT, - 'message' => 'Amount value 23..66 is not a numeric' - ] + 'message' => 'Amount value 23..66 is not a numeric', + ], ], [ [ 'value' => '24.99', - 'currencyCode' => 'FRA' + 'currencyCode' => 'FRA', ], [ 'class' => AmountException::class, 'code' => AmountException::INVALID_CURRENCY, - 'message' => 'Currency code FRA is not supported' - ] + 'message' => 'Currency code FRA is not supported', + ], ], [ [ 'value' => '24.99', - 'currencyCode' => 'JPY' + 'currencyCode' => 'JPY', ], [ 'class' => AmountException::class, 'code' => AmountException::UNEXPECTED_DECIMAL_AMOUNT, - 'message' => 'Currency code JPY does not support decimal amount' - ] - ] + 'message' => 'Currency code JPY does not support decimal amount', + ], + ], ]; } } diff --git a/tests/Unit/Discount/DiscountTest.php b/tests/Unit/Discount/DiscountTest.php index 72b20e843..e03f8bef1 100644 --- a/tests/Unit/Discount/DiscountTest.php +++ b/tests/Unit/Discount/DiscountTest.php @@ -39,54 +39,43 @@ public function validDiscountDataProvider() [ [ 'name' => '30EUR discount', - 'value' => '30' - ] + 'value' => '30', + ], ], [ [ 'name' => 'Black friday offer', - 'value' => '24.99' - ] - ] + 'value' => '24.99', + ], + ], ]; } public function invalidDiscountDataProvider() { return [ - [ - [ - 'name' => 14.99, - 'value' => '30' - ], - [ - 'class' => DiscountException::class, - 'code' => DiscountException::INVALID_NAME, - 'message' => 'Discount name is not a string' - ] - ], [ [ 'name' => '30EUR discount', - 'value' => 30 + 'value' => 30, ], [ 'class' => DiscountException::class, 'code' => DiscountException::INVALID_VALUE, - 'message' => 'Discount value is not supported' - ] + 'message' => 'Discount value is not supported', + ], ], [ [ 'name' => '50% discount', - 'value' => '50%' + 'value' => '50%', ], [ 'class' => DiscountException::class, 'code' => DiscountException::INVALID_VALUE, - 'message' => 'Discount value is not supported' - ] - ] + 'message' => 'Discount value is not supported', + ], + ], ]; } }