Skip to content

Commit

Permalink
[TASK] Raise TYPO3 version and dependencies
Browse files Browse the repository at this point in the history
Relates: #223
  • Loading branch information
extcode committed Oct 17, 2024
1 parent 822f2ed commit ebea834
Show file tree
Hide file tree
Showing 27 changed files with 214 additions and 437 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
strategy:
matrix:
php-version:
- 8.1
- 8.2
- 8.3
steps:
Expand Down Expand Up @@ -53,7 +52,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: "8.2"
tools: composer:v2

- name: Install dependencies
Expand All @@ -69,12 +68,10 @@ jobs:
strategy:
matrix:
include:
- php-version: '8.1'
typo3-version: '^12.4'
- php-version: '8.2'
typo3-version: '^12.4'
typo3-version: '^13.2'
- php-version: '8.3'
typo3-version: '^12.4'
typo3-version: '^13.2'
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -103,27 +100,18 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable

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

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

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

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

- 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 Acceptance Tests PHP8.1
run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-acceptance

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

Expand Down
64 changes: 20 additions & 44 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ stages:
- analysis

lint:cgl:
image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
image: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
stage: lint
before_script:
- sed -i -e "s#ssh://[email protected]:22722#https://gitlab-ci-token:[email protected]#g" composer.json
- composer config platform.php 8.1
- composer config platform.php 8.2
- composer remove typo3/cms-core --no-update
- composer install --no-progress --no-ansi --no-interaction
script:
- vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./

lint:typoscriptcgl:
image: php:8.1-alpine
image: php:8.2-alpine
stage: lint
before_script:
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev libzip-dev zip icu-dev g++
Expand All @@ -46,7 +46,7 @@ lint:typoscriptcgl:
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- sed -i -e "s#ssh://[email protected]:22722#https://gitlab-ci-token:[email protected]#g" composer.json
- composer config platform.php 8.1
- composer config platform.php 8.2
- composer remove typo3/cms-core --no-update
- composer install --no-progress --no-ansi --no-interaction
script:
Expand All @@ -66,12 +66,6 @@ lint:yaml:
script:
- find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l

lint:php81:
<<: *lint_php
stage: lint
variables:
CONTAINER_IMAGE: php:8.1-alpine

lint:php82:
<<: *lint_php
variables:
Expand All @@ -83,11 +77,11 @@ lint:php83:
CONTAINER_IMAGE: php:8.3-alpine

phpstan:analyse:
image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
image: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
stage: lint
before_script:
- sed -i -e "s#ssh://[email protected]:22722#https://gitlab-ci-token:[email protected]#g" composer.json
- composer config platform.php 8.1
- composer config platform.php 8.2
- composer install --no-progress --no-ansi --no-interaction
script:
- vendor/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M
Expand Down Expand Up @@ -120,28 +114,20 @@ phpstan:analyse:
expire_in: 1 day
when: always

# Build in PHP 8.1 and TYPO3 12.4
test:php81:typo3_12:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
TYPO3_VERSION: ^12.4
COVERAGE: 0

# Build in PHP 8.2 and TYPO3 12.4
test:php82:typo3_12:
# Build in PHP 8.2 and TYPO3 13.2
test:php82:typo3_13:
<<: *test_php
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
TYPO3_VERSION: ^12.4
TYPO3_VERSION: ^13.2
COVERAGE: 0

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

.test_codeception: &test_codeception
Expand All @@ -168,32 +154,22 @@ test:php83:typo3_12:
expire_in: 1 day
when: always

# Build in PHP 8.1 and TYPO3 12.4
test:codception:php81:typo3_12:
# Build in PHP 8.2 and TYPO3 13.2
test:codception:php82:typo3_13:
<<: *test_codeception
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.1:main
TYPO3_VERSION: ^12.4
GECKODRIVER_VERSION: v0.34.0

# Build in PHP 8.2 and TYPO3 12.4
test:codception:php82:typo3_12:
<<: *test_codeception
needs:
- test:codception:php81:typo3_12
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.2:main
TYPO3_VERSION: ^12.4
TYPO3_VERSION: ^13.2
GECKODRIVER_VERSION: v0.34.0

# Build in PHP 8.3 and TYPO3 12.4
test:codception:php83:typo3_12:
test:codception:php83:typo3_13:
<<: *test_codeception
needs:
- test:codception:php82:typo3_12
- test:codception:php82:typo3_13
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.3:main
TYPO3_VERSION: ^12.4
TYPO3_VERSION: ^13.2
GECKODRIVER_VERSION: v0.34.0

documentation:
Expand Down Expand Up @@ -223,7 +199,7 @@ sonarqube:
SONAR_SOURCES: "./Classes"
SONAR_GITLAB_PROJECT_ID: "$CI_PROJECT_ID"
script:
- echo "sonar.projectKey=cart_products-5.x" > sonar-project.properties
- echo "sonar.projectKey=cart_products-6.x" > sonar-project.properties
- gitlab-sonar-scanner -Dsonar.php.coverage.reportPath=phpunit.coverage.xml -Dsonar.php.tests.reportPath=phpunit.report.xml
allow_failure: true

Expand All @@ -239,5 +215,5 @@ sonarqube-reports:
SONAR_SOURCES: "./Classes"
SONAR_TESTS: "./Tests"
script:
- echo "sonar.projectKey=cart_products-5.x" > sonar-project.properties
- echo "sonar.projectKey=cart_products-6.x" > sonar-project.properties
- gitlab-sonar-scanner -Dsonar.php.coverage.reportPath=phpunit.coverage.xml -Dsonar.php.tests.reportPath=phpunit.report.xml
6 changes: 3 additions & 3 deletions Classes/Controller/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Extbase\Configuration\Exception;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\Request;
Expand All @@ -44,7 +44,7 @@ public function __construct(
protected readonly CategoryRepository $categoryRepository
) {}

protected function initializeAction()
protected function initializeAction(): void
{
$this->cartConfiguration = $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function getProduct(): ?Product

/**
* @return int|mixed
* @throws InvalidConfigurationTypeException
* @throws Exception
*/
public function getProductUid(): mixed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getStock(int $uid): int
->fetchOne();
}

public function addQuantityToStock(int $uid, int $quantity)
public function addQuantityToStock(int $uid, int $quantity): void
{
$currentStock = $this->getStock($uid);

Expand Down
38 changes: 22 additions & 16 deletions Classes/Domain/Repository/Product/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,30 @@ protected function createOrderingsFromDemand(ProductDemand $demand): array
{
$orderings = [];

if (is_null($demand->getOrder())) {
return $orderings;
}

$orderList = GeneralUtility::trimExplode(',', $demand->getOrder(), true);

if (!empty($orderList)) {
foreach ($orderList as $orderItem) {
[$orderField, $orderDirection] =
array_pad(
GeneralUtility::trimExplode(' ', $orderItem, true),
2,
'asc'
);
if (
$orderDirection &&
strtolower($orderDirection) === 'desc'
) {
$orderings[$orderField] = QueryInterface::ORDER_DESCENDING;
} else {
$orderings[$orderField] = QueryInterface::ORDER_ASCENDING;
}
if (empty($orderList)) {
return $orderings;
}

foreach ($orderList as $orderItem) {
[$orderField, $orderDirection] =
array_pad(
GeneralUtility::trimExplode(' ', $orderItem, true),
2,
'asc'
);
if (
$orderDirection &&
strtolower((string)$orderDirection) === 'desc'
) {
$orderings[$orderField] = QueryInterface::ORDER_DESCENDING;
} else {
$orderings[$orderField] = QueryInterface::ORDER_ASCENDING;
}
}

Expand Down
2 changes: 0 additions & 2 deletions Classes/EventListener/Create/CheckRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,5 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void
);
$event->setPropagationStopped(true);
}

return;
}
}
13 changes: 1 addition & 12 deletions Classes/EventListener/Create/CreateCartFrontendVariants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@
*/

use Extcode\Cart\Domain\Model\Cart\FeVariant;
use Extcode\CartProducts\Domain\Repository\Product\ProductRepository;
use Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class CreateCartFrontendVariants
{
protected ProductRepository $productRepository;

public function __construct(
ProductRepository $productRepository,
) {
$this->productRepository = $productRepository;
}
public function __construct() {}

public function __invoke(RetrieveProductsFromRequestEvent $event): void
{
Expand All @@ -40,8 +33,6 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void
return;
}

$feVariants = [];

$requestFeVariants = $request->getArgument('feVariants');

$cartProductFeVariants = [];
Expand All @@ -63,7 +54,5 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void
);
$event->setCartFeVariant($feVariant);
}

return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function getAllowedSettingsFromFlexForm(string $listType): array
}

$flexFormFile = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][$listType . ',list'];
$flexFormContent = file_get_contents(GeneralUtility::getFileAbsFileName(substr(trim($flexFormFile), 5)));
$flexFormContent = file_get_contents(GeneralUtility::getFileAbsFileName(substr(trim((string)$flexFormFile), 5)));
$flexFormData = GeneralUtility::xml2array($flexFormContent);

// Iterate each sheet and extract all settings
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Form/VariantSelectViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function getOptions(): array
if ($this->arguments['showOutOfStockMessage']) {
$labelOutofStock = LocalizationUtility::translate(
'tx_cartproducts.stock.out_of_stock',
'cart_products'
'CartProducts'
);
$optionLabel .= $labelOutofStock;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

class IfBestSpecialPriceAvailableViewHelper extends AbstractConditionViewHelper
{
/**
* @var bool
*/
protected $escapeOutput = false;

public function initializeArguments(): void
Expand All @@ -33,12 +30,7 @@ public function initializeArguments(): void
);
}

/**
* @param array|null $arguments
* @return bool
* @api
*/
protected static function evaluateCondition($arguments = null)
protected static function evaluateCondition(?array $arguments = null): bool
{
$product = $arguments['product'];
$bestSpecialPrice = $product->getBestSpecialPrice(self::getFrontendUserGroupIds());
Expand All @@ -48,6 +40,7 @@ protected static function evaluateCondition($arguments = null)
protected static function getFrontendUserGroupIds(): array
{
$context = GeneralUtility::makeInstance(Context::class);

return $context->getPropertyFromAspect('frontend.user', 'groupIds') ?? [];
}
}
Loading

0 comments on commit ebea834

Please sign in to comment.