Skip to content
Open
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
78 changes: 38 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -60,21 +61,19 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Coding Guideline
run: vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./
run: composer project:cgl

code-quality:
runs-on: ubuntu-latest
needs:
- php-linting
strategy:
matrix:
include:
- php-version: '8.2'
typo3-version: '^13.4'
- php-version: '8.3'
typo3-version: '^13.4'
- php-version: '8.4'
typo3-version: '^13.4'
php-version:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- uses: actions/checkout@v4

Expand All @@ -86,60 +85,56 @@ 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: Build codeception tester
run: vendor/bin/codecept build
run: .build/bin/codecept build

- name: Code Quality (by PHPStan)
run: vendor/bin/phpstan analyse -c Build/phpstan.neon
run: composer project:phpstan

test-php:
tests-unit-and-functional:
runs-on: ubuntu-latest
needs:
- coding-guideline
- code-quality
strategy:
matrix:
php-version:
- 8.2
- 8.3
- 8.4
- 8.5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v17
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
nix_path: nixpkgs=channel:nixos-unstable:phps=https://github.com/fossar/nix-phps/archive/master.tar.gz
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= fossar.cachix.org-1:Zv6FuqIboeHPWQS7ysLCJ7UT7xExb4OE8c4LyGb5AsE=
substituters = https://cache.nixos.org/ https://fossar.cachix.org

- 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 Unit Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-unit
php-version: "${{ matrix.php-version }}"
tools: composer:v2

- name: Run Functional Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-functional
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

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

- name: Run Functional Tests PHP8.4
run: nix-shell --arg phpVersion \"php84\" --pure --run project-test-functional
- name: Run functional tests
run: export typo3DatabaseDriver=pdo_sqlite && composer project:test:functional

test-acceptance:
runs-on: ubuntu-latest
needs:
- test-php
- tests-unit-and-functional
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5

- uses: cachix/install-nix-action@v17
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable:phps=https://github.com/fossar/nix-phps/archive/master.tar.gz
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= fossar.cachix.org-1:Zv6FuqIboeHPWQS7ysLCJ7UT7xExb4OE8c4LyGb5AsE=
substituters = https://cache.nixos.org/ https://fossar.cachix.org
nix_path: nixpkgs=channel:nixos-unstable

- name: Run Acceptance Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-acceptance
Expand All @@ -149,3 +144,6 @@ jobs:

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

- name: Run Acceptance Tests PHP8.5
run: nix-shell --arg phpVersion \"php85\" --pure --run project-test-acceptance
5 changes: 5 additions & 0 deletions Build/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
(new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(__DIR__ . '/../')
->exclude(
[
'var/',
]
)
)
->setRiskyAllowed(true)
->setRules([
Expand Down
3 changes: 1 addition & 2 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ parameters:
- ../Classes
- ../Configuration
- ../Tests
- ../ext_emconf.php
- ../ext_localconf.php
excludePaths:
- '../Tests/Acceptance/Support/_generated/TesterActions.php'
- ../Tests/Acceptance/Support/_generated

disallowedFunctionCalls:
-
Expand Down
2 changes: 1 addition & 1 deletion Build/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../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" 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">
<coverage/>
<testsuites>
<testsuite name="functional">
Expand Down
21 changes: 21 additions & 0 deletions Classes/Configuration/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Extcode\CartEvents\Configuration;

/*
* This file is part of the package extcode/cart-events
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

class Constants
{
/**
* Named constants for "magic numbers" of the field doktype.
*/
public const DOKTYPE_CARTEVENTS_EVENTS = 185;
public const DOKTYPE_CARTEVENTS_EVENT = 186;
}
15 changes: 8 additions & 7 deletions Classes/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

use Exception;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Service\SessionHandler;
Expand All @@ -25,11 +24,13 @@
use Extcode\CartEvents\Domain\Repository\EventRepository;
use Extcode\CartEvents\Domain\Repository\PriceCategoryRepository;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Cache\CacheTag;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation\IgnoreValidation;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Http\ForwardResponse;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface;

final class EventController extends ActionController
{
Expand All @@ -56,7 +57,7 @@ protected function initializeAction(): void
static $cacheTagsSet = false;

if (!$cacheTagsSet) {
$GLOBALS['TSFE']->addCacheTags(['tx_cartevents']);
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(new CacheTag('tx_cartevents', 3600));
$cacheTagsSet = true;
}
}
Expand Down Expand Up @@ -102,8 +103,8 @@ public function teaserAction(): ResponseInterface

public function showAction(?Event $event = null): ResponseInterface
{
if ((int)$GLOBALS['TSFE']->page['doktype'] === 186) {
$eventUid = (int)$GLOBALS['TSFE']->page['cart_events_event'];
if ((int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['doktype'] === 186) {
$eventUid = (int)$this->request->getAttribute('frontend.page.information')->getPageRecord()['cart_events_event'];
$event = $this->eventRepository->findByUid($eventUid);
}

Expand All @@ -120,8 +121,8 @@ public function showAction(?Event $event = null): ResponseInterface
#[IgnoreValidation(['value' => 'priceCategory'])]
public function formAction(?EventDate $eventDate = null, ?PriceCategory $priceCategory = null): ResponseInterface
{
if (class_exists(\TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface::class) === false) {
throw new \BadFunctionCallException('This action requires the installation of typo3/cms-form.');
if (class_exists(FormPersistenceManagerInterface::class) === false) {
throw new \BadFunctionCallException('This action requires the installation of typo3/cms-form.', 2153916883);
}

if (!$eventDate) {
Expand All @@ -142,7 +143,7 @@ public function formAction(?EventDate $eventDate = null, ?PriceCategory $priceCa
}
$formDefinition = $event->getFormDefinition();
$formPersistenceManager = GeneralUtility::makeInstance(
\TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface::class
FormPersistenceManagerInterface::class
);
$form = $formPersistenceManager->load($formDefinition);

Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/EventDateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

use Extcode\CartEvents\Domain\Repository\EventDateRepository;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Cache\CacheTag;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

Expand All @@ -28,7 +28,7 @@ protected function initializeAction(): void
static $cacheTagsSet = false;

if (!$cacheTagsSet) {
$GLOBALS['TSFE']->addCacheTags(['tx_cartevents']);
$this->request->getAttribute('frontend.cache.collector')->addCacheTags(new CacheTag('tx_cartevents', 3600));
$cacheTagsSet = true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Event extends AbstractEntity

protected ?string $formDefinition = null;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected string $teaser = '';
Expand All @@ -54,7 +54,7 @@ class Event extends AbstractEntity
/**
* @var ObjectStorage<EventDate>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $eventDates;

/**
Expand Down
10 changes: 5 additions & 5 deletions Classes/Domain/Model/EventDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class EventDate extends AbstractEventDate
{
protected Event $event;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected string $location = '';
Expand All @@ -49,15 +49,15 @@ class EventDate extends AbstractEventDate
/**
* @var ObjectStorage<SpecialPrice>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $specialPrices;

protected bool $priceCategorized = false;

/**
* @var ObjectStorage<PriceCategory>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $priceCategories;

protected bool $handleSeats = false;
Expand All @@ -71,7 +71,7 @@ class EventDate extends AbstractEventDate
/**
* @var ObjectStorage<CalendarEntry>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $calendarEntries;

public function __construct()
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/PriceCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class PriceCategory extends AbstractEntity
{
protected EventDate $eventDate;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $sku = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

protected float $price = 0.0;

/**
* @var ObjectStorage<SpecialPrice>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade(value: 'remove')]
protected ObjectStorage $specialPrices;

protected int $seatsNumber = 0;
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/SpecialPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

class SpecialPrice extends AbstractEntity
{
#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $title = '';

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected float $price = 0.0;

protected ?FrontendUserGroup $frontendUserGroup = null;
Expand Down
9 changes: 8 additions & 1 deletion Classes/Domain/Repository/EventDateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@

class EventDateRepository extends Repository
{
/**
* Constructs a new Repository
*/
public function __construct(private readonly ConnectionPool $connectionPool)
{
parent::__construct();
}
public function findNext(int $limit, string $pidList): array
{
$table = 'tx_cartevents_domain_model_eventdate';
$joinTableEvent = 'tx_cartevents_domain_model_event';

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
$queryBuilder = $this->connectionPool
->getQueryBuilderForTable($table);

$queryBuilder
Expand Down
Loading
Loading