Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Add CI test for PHP 8.4 #612

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ jobs:
matrix:
include:
- php-version: '8.2'
typo3-version: '^13.2'
typo3-version: '^13.4'
- php-version: '8.3'
typo3-version: '^13.2'
typo3-version: '^13.4'
- php-version: '8.4'
typo3-version: '^13.4'
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -126,9 +128,15 @@ jobs:
- name: Run Unit Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit

- name: Run Unit Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit

- name: Run Functional Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional

20 changes: 16 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ lint:php83:
variables:
CONTAINER_IMAGE: php:8.3-alpine

lint:php84:
<<: *lint_php
variables:
CONTAINER_IMAGE: php:8.4-alpine

phpstan:analyse:
image: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
stage: lint
Expand Down Expand Up @@ -94,19 +99,26 @@ phpstan:analyse:
- .build/bin/phpunit -c Build/UnitTests.xml
- typo3DatabaseDriver=pdo_sqlite .build/bin/phpunit -c Build/FunctionalTests.xml

# Build in PHP 8.2 and TYPO3 13.3
# Build in PHP 8.2 and TYPO3 13.4
test:php82:typo3_13:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
TYPO3_VERSION: ^13.3
TYPO3_VERSION: ^13.4

# Build in PHP 8.3 and TYPO3 13.2
# Build in PHP 8.3 and TYPO3 13.4
test:php83:typo3_13:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main
TYPO3_VERSION: ^13.3
TYPO3_VERSION: ^13.4

# Build in PHP 8.4 and TYPO3 13.4
test:php84:typo3_13:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.4:main
TYPO3_VERSION: ^13.4

documentation:
stage: documentation
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/Cart/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class CartController extends ActionController
{
public function showAction(
Item $orderItem = null,
BillingAddress $billingAddress = null,
ShippingAddress $shippingAddress = null
?Item $orderItem = null,
?BillingAddress $billingAddress = null,
?ShippingAddress $shippingAddress = null
): ResponseInterface {
$this->restoreSession();

Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/Cart/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function initializeCreateAction(): void

#[IgnoreValidation(['value' => 'shippingAddress'])]
public function createAction(
Item $orderItem = null,
BillingAddress $billingAddress = null,
ShippingAddress $shippingAddress = null
?Item $orderItem = null,
?BillingAddress $billingAddress = null,
?ShippingAddress $shippingAddress = null
): ResponseInterface {
$this->restoreSession();

Expand Down
9 changes: 0 additions & 9 deletions Classes/Controller/Cart/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\Cart\Event\CheckProductAvailabilityEvent;
use Extcode\Cart\Event\RetrieveProductsFromRequestEvent;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
Expand All @@ -24,14 +23,6 @@ class ProductController extends ActionController
{
public const AJAX_CART_TYPE_NUM = '2278001';

public function __construct(
EventDispatcherInterface $eventDispatcher = null
) {
if ($eventDispatcher !== null) {
$this->eventDispatcher = $eventDispatcher;
}
}

public function addAction(): ResponseInterface
{
if (!$this->request->hasArgument('productType')) {
Expand Down
104 changes: 32 additions & 72 deletions Classes/Domain/Model/Cart/BeVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

class BeVariant
{
protected ?Product $product = null;

protected ?BeVariant $parentBeVariant = null;

protected string $titleDelimiter = ' - ';

protected string $skuDelimiter = '-';
Expand Down Expand Up @@ -45,30 +41,13 @@ class BeVariant

public function __construct(
protected string $id,
Product $product = null,
self $beVariant = null,
protected self|Product $parent,
protected string $title,
protected string $sku,
protected int $priceCalcMethod,
protected float $price,
protected int $quantity = 0
) {
if ($product === null && $beVariant === null) {
throw new \InvalidArgumentException();
}

if ($product != null && $beVariant != null) {
throw new \InvalidArgumentException();
}

if ($product !== null) {
$this->product = $product;
}

if ($beVariant !== null) {
$this->parentBeVariant = $beVariant;
}

$this->reCalc();
}

Expand Down Expand Up @@ -102,36 +81,28 @@ public function toArray(): array
return $variantArr;
}

public function getProduct(): ?Product
public function getParent(): self|Product
{
return $this->product;
return $this->parent;
}

public function setProduct(Product $product): void
public function setParent(self|Product $parent): void
{
$this->product = $product;
$this->parent = $parent;
}

public function getParentBeVariant(): ?self
public function getProduct(): Product
{
return $this->parentBeVariant;
}
if ($this->parent instanceof Product) {
return $this->parent;
}

public function setParentBeVariant(self $parentBeVariant): void
{
$this->parentBeVariant = $parentBeVariant;
return $this->parent->getProduct();
}

public function isNetPrice(): bool
{
if ($this->getParentBeVariant()) {
return $this->getParentBeVariant()->isNetPrice();
}
if ($this->getProduct()) {
return $this->getProduct()->isNetPrice();
}

return false;
return $this->parent->isNetPrice();
}

public function getId(): string
Expand All @@ -158,10 +129,10 @@ public function getCompleteTitle(): string
{
$title = '';

if ($this->getParentBeVariant()) {
$title = $this->getParentBeVariant()->getCompleteTitle();
} elseif ($this->getProduct()) {
$title = $this->getProduct()->getTitle();
if ($this->parent instanceof self) {
$title = $this->parent->getCompleteTitle();
} elseif ($this->parent instanceof Product) {
$title = $this->parent->getTitle();
}

if ($this->isFeVariant) {
Expand All @@ -178,8 +149,8 @@ public function getCompleteTitleWithoutProduct(): string
$title = '';
$titleDelimiter = '';

if ($this->getParentBeVariant()) {
$title = $this->getParentBeVariant()->getCompleteTitleWithoutProduct();
if ($this->parent instanceof self) {
$title = $this->parent->getCompleteTitleWithoutProduct();
$titleDelimiter = $this->titleDelimiter;
}

Expand Down Expand Up @@ -244,12 +215,12 @@ public function getPriceCalculated(): float
{
$price = $this->getBestPrice();

if ($this->getParentBeVariant()) {
$parentPrice = $this->getParentBeVariant()->getBestPrice();
} elseif ($this->getProduct()) {
$parentPrice = $this->getProduct()->getBestPrice($this->getQuantity());
if ($this->parent instanceof self) {
$parentPrice = $this->parent->getBestPrice();
} elseif ($this->parent instanceof Product) {
$parentPrice = $this->parent->getBestPrice($this->getQuantity());
} else {
$parentPrice = 0;
$parentPrice = 0.0;
}

if ($this->priceCalcMethod === 0) {
Expand Down Expand Up @@ -285,15 +256,11 @@ public function getParentPrice(): float
return 0.0;
}

if ($this->getParentBeVariant()) {
return $this->getParentBeVariant()->getBestPrice();
if ($this->parent instanceof self) {
return $this->parent->getBestPrice();
}

if ($this->getProduct()) {
return $this->getProduct()->getBestPrice($this->getQuantity());
}

return 0.0;
return $this->parent->getBestPrice($this->getQuantity());
}

public function setPrice(float $price): void
Expand Down Expand Up @@ -332,10 +299,10 @@ public function getCompleteSku(): string
{
$sku = '';

if ($this->getParentBeVariant()) {
$sku = $this->getParentBeVariant()->getCompleteSku();
} elseif ($this->getProduct()) {
$sku = $this->getProduct()->getSku();
if ($this->parent instanceof self) {
$sku = $this->parent->getCompleteSku();
} elseif ($this->parent instanceof Product) {
$sku = $this->parent->getSku();
}

if ($this->isFeVariant) {
Expand All @@ -353,8 +320,8 @@ public function getCompleteSkuWithoutProduct(): string

$skuDelimiter = '';

if ($this->getParentBeVariant()) {
$sku = $this->getParentBeVariant()->getCompleteSkuWithoutProduct();
if ($this->parent instanceof self) {
$sku = $this->parent->getCompleteSkuWithoutProduct();
$skuDelimiter = $this->titleDelimiter;
}

Expand Down Expand Up @@ -416,14 +383,7 @@ public function getTax(): float

public function getTaxClass(): ?TaxClass
{
if ($this->getParentBeVariant()) {
return $this->getParentBeVariant()->getTaxClass();
}
if ($this->getProduct()) {
return $this->getProduct()->getTaxClass();
}

return null;
return $this->parent->getTaxClass();
}

public function setQuantity(int $newQuantity): void
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ public function setCurrencySign(string $currencySign): void
$this->currencySign = $currencySign;
}

public function translatePrice(float $price = null): ?float
public function translatePrice(?float $price = null): ?float
{
if ($price !== null) {
$price /= $this->getCurrencyTranslation();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Cart/Extra.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
protected TaxClass $taxClass,
protected bool $isNetPrice = false,
protected string $extraType = '',
Service $service = null
?Service $service = null
) {
$this->service = $service;

Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Model/Cart/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
protected TaxClass $taxClass,
protected int $quantity,
protected bool $isNetPrice = false,
FeVariant $feVariant = null
?FeVariant $feVariant = null
) {
if ($feVariant) {
$this->feVariant = $feVariant;
Expand Down Expand Up @@ -130,7 +130,7 @@ public function addBeVariant(BeVariant $newVariant): void
$variant->setQuantity($newQuantity);
}
} else {
$newVariant->setProduct($this);
$newVariant->setParent($this);
$this->beVariants[$newVariantsId] = $newVariant;
}

Expand Down Expand Up @@ -275,7 +275,7 @@ public function getQuantityDiscounts(): array
return $this->quantityDiscounts;
}

public function getQuantityDiscountPrice(int $quantity = null): float
public function getQuantityDiscountPrice(?int $quantity = null): float
{
$price = $this->getTranslatedPrice();

Expand All @@ -300,7 +300,7 @@ public function setQuantityDiscounts(array $quantityDiscounts): void
/**
* Returns Best Price (min of Price and Special Price)
*/
public function getBestPrice(int $quantity = null): ?float
public function getBestPrice(?int $quantity = null): ?float
{
$bestPrice = $this->getQuantityDiscountPrice($quantity);

Expand Down
Loading
Loading