Skip to content

Commit a2fc545

Browse files
authored
Merge pull request #23 from JanKlett/main
[FEATURE] Upgrade to typo3 v14
2 parents 2db16ad + 92fa20d commit a2fc545

11 files changed

Lines changed: 530 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,44 @@ jobs:
77

88
runs-on: ubuntu-latest
99
strategy:
10+
fail-fast: false
1011
matrix:
11-
TYPO3: ['11' , '12', '13']
12+
TYPO3: ['13', '14']
1213

1314
steps:
1415
- name: Checkout
15-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1617

1718
- name: Set up PHP Version
1819
uses: shivammathur/setup-php@v2
1920
with:
2021
php-version: 8.3
2122
tools: composer:v2
2223

23-
- name: Validate composer.json and composer.lock
24-
run: composer validate
24+
- name: Validate composer.json
25+
run: composer validate --no-check-lock
2526

2627
- name: Cache dependencies
27-
uses: actions/cache@v1
28+
uses: actions/cache@v4
2829
with:
2930
path: ~/.composer/cache
30-
key: dependencies-composer-${{ hashFiles('composer.json') }}
31+
key: dependencies-composer-${{ matrix.TYPO3 }}-${{ hashFiles('composer.json') }}
32+
33+
- name: Install composer dependencies TYPO3 14
34+
if: matrix.TYPO3 == '14'
35+
run: |
36+
composer require typo3/cms-core:^14.0 typo3/cms-frontend:^14.0 --no-progress --no-interaction -W
3137
3238
- name: Install composer dependencies TYPO3 13
3339
if: matrix.TYPO3 == '13'
3440
run: |
35-
composer install --no-progress --no-interaction
41+
composer require typo3/cms-core:^13.4 typo3/cms-frontend:^13.4 --no-progress --no-interaction -W
42+
43+
- name: Unit Tests
44+
run: ./vendor/bin/phpunit -c Build/phpunit/UnitTests.xml
3645

37-
- name: Install composer dependencies TYPO3 12
38-
if: matrix.TYPO3 == '12'
39-
run: |
40-
composer require typo3/cms-core:^12.4 --no-progress --no-interaction --dev -W
41-
- name: Install composer dependencies TYPO3 11
42-
if: matrix.TYPO3 == '11'
43-
run: |
44-
composer require typo3/cms-core:^11.5 --no-progress --no-interaction --dev -W
4546
- name: Phpstan
4647
run: ./vendor/bin/phpstan analyze -c phpstan.neon
48+
4749
- name: Phpcsfix
4850
run: ./vendor/bin/php-cs-fixer fix --config=php-cs-fixer.php --dry-run --stop-on-violation --using-cache=no

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/public/
33
/vendor/
44
/.php-cs-fixer.cache
5+
/Build/phpunit/.phpunit.cache/

Build/phpunit/UnitTests.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
5+
bootstrap="UnitTestsBootstrap.php"
6+
cacheDirectory=".phpunit.cache"
7+
colors="true"
8+
failOnWarning="true"
9+
failOnDeprecation="true"
10+
failOnNotice="true"
11+
failOnRisky="true"
12+
beStrictAboutTestsThatDoNotTestAnything="true"
13+
>
14+
<testsuites>
15+
<testsuite name="Unit tests">
16+
<directory>../../Tests/Unit/</directory>
17+
</testsuite>
18+
</testsuites>
19+
<source>
20+
<include>
21+
<directory>../../src/</directory>
22+
</include>
23+
</source>
24+
</phpunit>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of TYPO3 CMS-based extension "JustInCase" by b13.
7+
*
8+
* It is free software; you can redistribute it and/or modify it under
9+
* the terms of the GNU General Public License, either version 2
10+
* of the License, or any later version.
11+
*/
12+
13+
$autoloader = dirname(__DIR__, 2) . '/vendor/autoload.php';
14+
if (!file_exists($autoloader)) {
15+
die('Please run "composer install" before running the unit tests.' . PHP_EOL);
16+
}
17+
require $autoloader;

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ both URLs would work for the users.
1616

1717
Use it via `composer req b13/justincase` or install the Extension `justincase` from the TYPO3 Extension Repository.
1818

19-
_justincase_ requires TYPO3 v9.5.0 or later.
19+
_justincase_ requires TYPO3 v13.4 or later (v13.4 and v14 are supported).
20+
21+
For TYPO3 v11.5 and v12.4, use the 2.x release line.
2022

2123
## Configuration
2224

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace B13\JustInCase\Tests\Unit\Middleware;
6+
7+
/*
8+
* This file is part of TYPO3 CMS-based extension "JustInCase" by b13.
9+
*
10+
* It is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License, either version 2
12+
* of the License, or any later version.
13+
*/
14+
15+
use B13\JustInCase\Middleware\BeforeMiddlewareIsAppliedEvent;
16+
use PHPUnit\Framework\Attributes\Test;
17+
use PHPUnit\Framework\TestCase;
18+
use TYPO3\CMS\Core\Http\ServerRequest;
19+
20+
final class BeforeMiddlewareIsAppliedEventTest extends TestCase
21+
{
22+
#[Test]
23+
public function middlewareIsAppliedByDefault(): void
24+
{
25+
$event = new BeforeMiddlewareIsAppliedEvent(new ServerRequest('https://example.com/Foo'));
26+
27+
self::assertTrue($event->shouldBeApplied());
28+
}
29+
30+
#[Test]
31+
public function doNotApplyPreventsMiddlewareFromBeingApplied(): void
32+
{
33+
$event = new BeforeMiddlewareIsAppliedEvent(new ServerRequest('https://example.com/Foo'));
34+
35+
$event->doNotApply();
36+
37+
self::assertFalse($event->shouldBeApplied());
38+
}
39+
40+
#[Test]
41+
public function serverRequestIsExposedToListeners(): void
42+
{
43+
$request = new ServerRequest('https://example.com/Foo');
44+
$event = new BeforeMiddlewareIsAppliedEvent($request);
45+
46+
self::assertSame($request, $event->getServerRequest());
47+
}
48+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace B13\JustInCase\Tests\Unit\Middleware\Fixtures;
6+
7+
/*
8+
* This file is part of TYPO3 CMS-based extension "JustInCase" by b13.
9+
*
10+
* It is free software; you can redistribute it and/or modify it under
11+
* the terms of the GNU General Public License, either version 2
12+
* of the License, or any later version.
13+
*/
14+
15+
use Psr\Http\Message\ServerRequestInterface;
16+
use Psr\Http\Message\UriInterface;
17+
use TYPO3\CMS\Core\Context\Context;
18+
use TYPO3\CMS\Core\Routing\RouteNotFoundException;
19+
use TYPO3\CMS\Core\Routing\RouteResultInterface;
20+
use TYPO3\CMS\Core\Routing\RouterInterface;
21+
use TYPO3\CMS\Core\Routing\SiteRouteResult;
22+
use TYPO3\CMS\Core\Site\Entity\Site;
23+
24+
/**
25+
* A Site whose router only matches an explicit list of paths.
26+
*
27+
* Site::getRouter() builds a PageRouter via GeneralUtility::makeInstance and needs
28+
* a database, so it is replaced here to keep these tests pure unit tests.
29+
*/
30+
final class RoutableSite extends Site
31+
{
32+
/**
33+
* @param string[] $matchingPaths paths the router resolves; everything else throws
34+
*/
35+
public function __construct(
36+
string $identifier,
37+
int $rootPageId,
38+
array $configuration,
39+
private readonly array $matchingPaths = []
40+
) {
41+
parent::__construct($identifier, $rootPageId, $configuration);
42+
}
43+
44+
public function getRouter(?Context $context = null): RouterInterface
45+
{
46+
return new class($this, $this->matchingPaths) implements RouterInterface {
47+
/**
48+
* @param string[] $matchingPaths
49+
*/
50+
public function __construct(
51+
private readonly Site $site,
52+
private readonly array $matchingPaths
53+
) {
54+
}
55+
56+
public function matchRequest(
57+
ServerRequestInterface $request,
58+
?RouteResultInterface $previousResult = null
59+
): RouteResultInterface {
60+
if (!in_array($request->getUri()->getPath(), $this->matchingPaths, true)) {
61+
throw new RouteNotFoundException('No route found', 1579000000);
62+
}
63+
return new SiteRouteResult($request->getUri(), $this->site, null);
64+
}
65+
66+
public function generateUri(
67+
$route,
68+
array $parameters = [],
69+
string $fragment = '',
70+
string $type = self::ABSOLUTE_URL
71+
): UriInterface {
72+
throw new \BadMethodCallException('Not needed in these tests', 1579000001);
73+
}
74+
};
75+
}
76+
}

0 commit comments

Comments
 (0)