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] Raise TYPO3 version and dependencies #584

Merged
merged 1 commit into from
Oct 24, 2024
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
19 changes: 6 additions & 13 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 @@ -71,7 +70,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 @@ -87,12 +86,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 All @@ -104,7 +101,9 @@ jobs:

- name: Install dependencies with expected TYPO3 version
run: |-
composer require --no-interaction --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}"
composer remove --dev ssch/typo3-rector \
&& composer require typo3/cms-install "*" \
&& composer install --no-progress --no-ansi --no-interaction

- name: Code Quality (by PHPStan)
run: .build/bin/phpstan analyse -c Build/phpstan.neon
Expand All @@ -121,18 +120,12 @@ jobs:
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Run Unit Tests PHP8.1
run: nix-shell --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 --pure --run project-test-functional

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

Expand Down
40 changes: 14 additions & 26 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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:
- composer remove typo3/cms-core --no-update
Expand Down Expand Up @@ -54,13 +54,7 @@ lint:yaml:
stage: lint
image: $CONTAINER_IMAGE
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
- find *.php Classes Configuration Tests

lint:php82:
<<: *lint_php
Expand All @@ -73,10 +67,12 @@ 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:
- composer config platform.php 8.1
- composer config platform.php 8.2
- composer remove --dev ssch/typo3-rector
- composer require typo3/cms-install "*"
- composer install --no-progress --no-ansi --no-interaction
script:
- .build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M
Expand Down Expand Up @@ -112,28 +108,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.3
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.3
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.3
COVERAGE: 1

documentation:
Expand Down Expand Up @@ -163,7 +151,7 @@ sonarqube:
SONAR_SOURCES: "./Classes"
SONAR_GITLAB_PROJECT_ID: "$CI_PROJECT_ID"
script:
- echo "sonar.projectKey=cart-9.x" > sonar-project.properties
- echo "sonar.projectKey=cart-10.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 @@ -179,5 +167,5 @@ sonarqube-reports:
SONAR_SOURCES: "./Classes"
SONAR_TESTS: "./Tests"
script:
- echo "sonar.projectKey=cart-9.x" > sonar-project.properties
- echo "sonar.projectKey=cart-10.x" > sonar-project.properties
- gitlab-sonar-scanner -Dsonar.php.coverage.reportPath=phpunit.coverage.xml -Dsonar.php.tests.reportPath=phpunit.report.xml
18 changes: 17 additions & 1 deletion Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheResult="false"
colors="true"
failOnDeprecation="true"
failOnWarning="true"
failOnRisky="true"
processIsolation="false"
requireCoverageMetadata="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
>
<coverage/>
<testsuites>
<testsuite name="Cart Extension">
Expand Down
18 changes: 17 additions & 1 deletion Build/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
cacheResult="false"
colors="true"
failOnDeprecation="true"
failOnWarning="true"
failOnRisky="true"
processIsolation="false"
requireCoverageMetadata="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
>
<coverage/>
<testsuites>
<testsuite name="Cart Extension">
Expand Down
5 changes: 0 additions & 5 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ parameters:
message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#"
count: 1
path: ../Classes/EventListener/Order/Finish/ClearCart.php

-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../Classes/View/CartTemplateView.php
4 changes: 2 additions & 2 deletions Classes/Controller/Backend/Order/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Pagination\SimplePagination;
Expand Down Expand Up @@ -275,7 +275,7 @@ private function setDocHeader(array $buttons): void

foreach ($buttons as $button) {
$title = $this->getLanguageService()->sL(self::LANG_FILE . $button['title']);
$icon = $this->iconFactory->getIcon($button['icon'], Icon::SIZE_SMALL);
$icon = $this->iconFactory->getIcon($button['icon'], IconSize::SMALL->value);

$viewButton = $buttonBar->makeLinkButton()
->setHref($button['link'])
Expand Down
70 changes: 31 additions & 39 deletions Classes/Controller/Cart/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,12 @@
use Extcode\Cart\Domain\Model\Order\ShippingAddress;
use Extcode\Cart\Event\Cart\BeforeShowCartEvent;
use Extcode\Cart\Event\CheckProductAvailabilityEvent;
use Extcode\Cart\View\CartTemplateView;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;

class CartController extends ActionController
{
public function __construct()
{
$this->defaultViewObjectName = CartTemplateView::class;
}

protected function initializeView(CartTemplateView $view): void
{
if ($this->request->getControllerActionName() !== 'show') {
return;
}

if (!isset($this->settings['cart']['steps'])) {
return;
}

$steps = (int)($this->settings['cart']['steps'] ?? 0);
if ($steps > 1) {
if ($this->request->hasArgument('step')) {
$currentStep = (int)$this->request->getArgument('step') ?: 1;
} else {
$currentStep = 1;
}

if ($currentStep > $steps) {
throw new \InvalidArgumentException();
}
$view->setStep($currentStep);

if ($currentStep < $steps) {
$view->assign('nextStep', $currentStep + 1);
}
if ($currentStep > 1) {
$view->assign('previousStep', $currentStep - 1);
}
}
}

public function showAction(
Item $orderItem = null,
BillingAddress $billingAddress = null,
Expand Down Expand Up @@ -146,9 +108,12 @@ public function showAction(
return $this->redirect('show', null, null, ['step' => 1])->withStatus(303);
}

$template = $this->getTemplateForShowAction();

$this->dispatchModifyViewEvent();

return $this->htmlResponse();
return $this->htmlResponse($this->view->render($template));

}

public function clearAction(): ResponseInterface
Expand Down Expand Up @@ -206,4 +171,31 @@ public function updateAction(): ResponseInterface

return $this->redirect('show');
}

private function getTemplateForShowAction(): string
{
$steps = (int)($this->settings['cart']['steps'] ?? 1);

if ($steps === 1) {
return 'Show';
}

$currentStep = 1;
if ($this->request->hasArgument('step')) {
$currentStep = (int)$this->request->getArgument('step') ?: 1;
}

if ($currentStep > $steps) {
throw new \InvalidArgumentException();
}

if ($currentStep < $steps) {
$this->view->assign('nextStep', $currentStep + 1);
}
if ($currentStep > 1) {
$this->view->assign('previousStep', $currentStep - 1);
}

return 'ShowStep' . $currentStep;
}
}
4 changes: 2 additions & 2 deletions Classes/Controller/Cart/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

class OrderController extends ActionController
{
protected function getErrorFlashMessage(): ?string
protected function getErrorFlashMessage(): bool|string
{
return LocalizationUtility::translate(
'tx_cart.error.validation',
'Cart'
);
) ?? false;
}

public function initializeCreateAction(): void
Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Model/Cart/TaxClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* LICENSE file that was distributed with this source code.
*/

final class TaxClass implements TaxClassInterface
final readonly class TaxClass implements TaxClassInterface
{
public function __construct(
private readonly int $id,
private readonly string $value,
private readonly float $calc,
private readonly string $title
private int $id,
private string $value,
private float $calc,
private string $title
) {}

public function getId(): int
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Cart/TaxClassFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

use Psr\Log\LoggerInterface;

final class TaxClassFactory implements TaxClassFactoryInterface
final readonly class TaxClassFactory implements TaxClassFactoryInterface
{
public function __construct(
private readonly LoggerInterface $logger
private LoggerInterface $logger
) {}

public function getTaxClass(int $taxClassKey, array $taxClassValue): ?TaxClass
Expand Down
6 changes: 3 additions & 3 deletions Classes/Event/Cart/UpdateCountryEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
use Extcode\Cart\Domain\Model\Cart\Cart;
use TYPO3\CMS\Extbase\Mvc\Request;

final class UpdateCountryEvent implements UpdateCountryEventInterface
final readonly class UpdateCountryEvent implements UpdateCountryEventInterface
{
public function __construct(
private readonly Cart $cart,
private readonly Request $request
private Cart $cart,
private Request $request
) {}

public function getCart(): Cart
Expand Down
Loading
Loading