Skip to content

Commit

Permalink
Fixing CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
btafforeau committed Nov 24, 2023
1 parent d3b9efc commit 5fbfb80
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 66 deletions.
26 changes: 23 additions & 3 deletions src/Category/Category.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA and Contributors <[email protected]>
* @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';
}
18 changes: 1 addition & 17 deletions src/Discount/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Discount
*/
public function __construct($name, $value)
{
$this->name = $this->assertDiscountNameIsValid($name);
$this->name = $name;
$this->value = $this->assertDiscountValueIsValid($value);
}

Expand All @@ -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
*
Expand Down
1 change: 0 additions & 1 deletion src/Product/Exception/ProductException.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@

class ProductException extends PsCheckoutException
{

}
6 changes: 3 additions & 3 deletions src/Product/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class Product
/** @var int */
private $quantity;

/** @var boolean */
/** @var bool */
private $isInStock;

/** @var boolean */
/** @var bool */
private $isAvailableForOrder;

/** @var string */
Expand Down Expand Up @@ -77,7 +77,7 @@ public function getUnitPrice()
}

/**
* @return string
* @return int
*/
public function getQuantity()
{
Expand Down
38 changes: 19 additions & 19 deletions tests/Unit/Amount/AmountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
];
}

Expand All @@ -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',
],
],
];
}
}
35 changes: 12 additions & 23 deletions tests/Unit/Discount/DiscountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
],
];
}
}

0 comments on commit 5fbfb80

Please sign in to comment.