From f26d776c86b22d67fc6bb9bbe05d302fa3957ffa Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 14:49:29 +0100 Subject: [PATCH 1/6] TASK: Add functional test setup and GitHub CI --- .github/workflows/tests.yml | 44 +++++++++ README.md | 14 +++ .../Fusion/AbstractFusionTestCase.php | 56 +++++++++++ .../Functional/Fusion/PaginationArrayTest.php | 95 +++++++++++++++++++ Tests/Functional/run-tests.sh | 37 ++++++++ Tests/Functional/setup-test-distribution.sh | 91 ++++++++++++++++++ composer.json | 5 + 7 files changed, 342 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100644 Tests/Functional/Fusion/AbstractFusionTestCase.php create mode 100644 Tests/Functional/Fusion/PaginationArrayTest.php create mode 100755 Tests/Functional/run-tests.sh create mode 100755 Tests/Functional/setup-test-distribution.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..66695b2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,44 @@ +name: Tests + +on: + push: + branches: [ main, '[0-9]+.[0-9]+' ] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + functional-tests: + name: Functional tests (PHP ${{ matrix.php-version }}, Neos 8.3) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: [ '8.2', '8.3' ] + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl, pdo_sqlite + tools: composer:v2 + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" + + - uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'Tests/Functional/setup-test-distribution.sh') }} + restore-keys: composer-${{ runner.os }}-php${{ matrix.php-version }}- + + - name: Run functional tests + # builds a throwaway Neos distribution with this package symlinked into it, see the script + run: Tests/Functional/run-tests.sh "$RUNNER_TEMP/test-distribution" diff --git a/README.md b/README.md index b2ecd99..df49f4c 100644 --- a/README.md +++ b/README.md @@ -158,3 +158,17 @@ Sort nodes recursively by their sorting property. Example: ${q(site).find('[instanceof Neos.Neos:Document]').sortRecursiveByIndex('DESC').get()} + +# Running the tests + +The functional tests boot a Flow application, so they run inside a throwaway Neos distribution with this package +symlinked into it. The script creates the distribution on the first run (in your temp directory) and reuses it +afterwards: + + Tests/Functional/run-tests.sh + + # custom distribution directory and additional PHPUnit arguments + Tests/Functional/run-tests.sh /tmp/listable-tests -- --filter PaginationArrayTest + +Delete the distribution directory to start from scratch. The same script runs in the GitHub CI +(`.github/workflows/tests.yml`). diff --git a/Tests/Functional/Fusion/AbstractFusionTestCase.php b/Tests/Functional/Fusion/AbstractFusionTestCase.php new file mode 100644 index 0000000..2515dbc --- /dev/null +++ b/Tests/Functional/Fusion/AbstractFusionTestCase.php @@ -0,0 +1,56 @@ +union(FusionSourceCodeCollection::fromFilePath($fusionFile)); + } + $sourceCode = $sourceCode->union(FusionSourceCodeCollection::fromString($fusionSourceCode)); + + $runtime = $this->objectManager->get(RuntimeFactory::class) + ->createFromSourceCode($sourceCode, $this->buildControllerContext()); + + return $runtime->evaluate($fusionPath); + } + + private function buildControllerContext(): ControllerContext + { + $httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class) + ->createServerRequest('GET', 'http://localhost/'); + $request = ActionRequest::fromHttpRequest($httpRequest); + + $uriBuilder = new UriBuilder(); + $uriBuilder->setRequest($request); + + return new ControllerContext($request, new ActionResponse(), new Arguments([]), $uriBuilder); + } +} diff --git a/Tests/Functional/Fusion/PaginationArrayTest.php b/Tests/Functional/Fusion/PaginationArrayTest.php new file mode 100644 index 0000000..10be5cb --- /dev/null +++ b/Tests/Functional/Fusion/PaginationArrayTest.php @@ -0,0 +1,95 @@ +}> + * currentPage, numberOfPages, maximumNumberOfLinks, itemsPerPage, showPreviousNextLinks, expected links + */ + public function paginationDataProvider(): array + { + return [ + 'first page' => [1, 10, 5, 10, false, [1, 2, 3, '...', 10]], + 'middle page with gaps on both sides' => [5, 10, 5, 10, false, [1, '...', 4, 5, 6, '...', 10]], + 'last page' => [10, 10, 5, 10, false, [1, '...', 8, 9, 10]], + 'fewer pages than links' => [2, 3, 5, 10, false, [1, 2, 3]], + 'single page' => [1, 1, 5, 10, false, [1]], + 'previous and next links on a middle page' => [5, 10, 5, 10, true, ['previous', 1, '...', 4, 5, 6, '...', 10, 'next']], + 'no previous link on the first page' => [1, 10, 5, 10, true, [1, 2, 3, '...', 10, 'next']], + 'no next link on the last page' => [10, 10, 5, 10, true, ['previous', 1, '...', 8, 9, 10]], + ]; + } + + /** + * @test + * @dataProvider paginationDataProvider + * @param array $expectedLinks + */ + public function paginationArrayContainsExpectedLinks( + int $currentPage, + int $numberOfPages, + int $maximumNumberOfLinks, + int $itemsPerPage, + bool $showPreviousNextLinks, + array $expectedLinks + ): void { + $links = $this->evaluatePaginationArray( + $currentPage, + $numberOfPages * $itemsPerPage, + $maximumNumberOfLinks, + $itemsPerPage, + $showPreviousNextLinks + ); + + // compared as strings, the way they are rendered: the last page is computed with ceil() and is a float + self::assertSame(self::toStrings($expectedLinks), self::toStrings($links)); + } + + /** + * @test + */ + public function paginationArrayIsEmptyWithoutItems(): void + { + self::assertSame([], $this->evaluatePaginationArray(1, 0, 5, 10, false)); + } + + /** + * @param array $links + * @return array + */ + private static function toStrings(array $links): array + { + return array_map(static fn ($link): string => (string)$link, $links); + } + + /** + * @return array + */ + private function evaluatePaginationArray( + int $currentPage, + int $totalCount, + int $maximumNumberOfLinks, + int $itemsPerPage, + bool $showPreviousNextLinks + ): array { + return $this->evaluateFusion('pagination', sprintf( + 'pagination = Flowpack.Listable:PaginationArray { + currentPage = %d + totalCount = %d + maximumNumberOfLinks = %d + itemsPerPage = %d + showPreviousNextLinks = %s + }', + $currentPage, + $totalCount, + $maximumNumberOfLinks, + $itemsPerPage, + $showPreviousNextLinks ? 'true' : 'false' + )); + } +} diff --git a/Tests/Functional/run-tests.sh b/Tests/Functional/run-tests.sh new file mode 100755 index 0000000..f0cfeaf --- /dev/null +++ b/Tests/Functional/run-tests.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# Runs the functional tests of this package in a throwaway Neos distribution. +# +# Usage: Tests/Functional/run-tests.sh [target-directory] [-- additional phpunit arguments] +# +# The distribution is created on the first run (see setup-test-distribution.sh) and reused afterwards. +# Delete the target directory to start from scratch. +# +# Examples: +# Tests/Functional/run-tests.sh +# Tests/Functional/run-tests.sh /tmp/listable-tests -- --filter PaginationArrayTest +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TARGET_DIR="${TMPDIR:-/tmp}/flowpack-listable-test-distribution" +if [[ $# -gt 0 && "$1" != "--" ]]; then + TARGET_DIR="$1" + shift +fi +if [[ $# -gt 0 && "$1" == "--" ]]; then + shift +fi +TARGET_DIR="${TARGET_DIR%/}" + +if [[ ! -x "$TARGET_DIR/bin/phpunit" ]]; then + "$SCRIPT_DIR/setup-test-distribution.sh" "$TARGET_DIR" +fi + +cd "$TARGET_DIR" +# memory_limit = -1 for PHPUnit and every PHP process it starts (see setup-test-distribution.sh). +# The leading ":" keeps the system's scan dir and adds ours. +export PHP_INI_SCAN_DIR=":$TARGET_DIR/php-ini" +exec bin/phpunit \ + -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml \ + "$@" \ + Packages/Application/Flowpack.Listable/Tests/Functional diff --git a/Tests/Functional/setup-test-distribution.sh b/Tests/Functional/setup-test-distribution.sh new file mode 100755 index 0000000..e1b41b0 --- /dev/null +++ b/Tests/Functional/setup-test-distribution.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# +# Creates a minimal Neos distribution with this package installed (symlinked), to run the functional tests in. +# +# Functional tests boot a full Flow application, so they can't run from the package root alone. +# Used by run-tests.sh and the GitHub CI (.github/workflows/tests.yml). +# +# Usage: Tests/Functional/setup-test-distribution.sh [target-directory] +# +# The target directory must be OUTSIDE of this package: the package is symlinked into it. +set -euo pipefail + +PACKAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +TARGET_DIR="${1:-${TMPDIR:-/tmp}/flowpack-listable-test-distribution}" +TARGET_DIR="${TARGET_DIR%/}" + +case "$TARGET_DIR/" in + "$PACKAGE_DIR"/*) + echo "The target directory must be outside of the package directory ($PACKAGE_DIR)." >&2 + exit 1 + ;; +esac + +mkdir -p "$TARGET_DIR" + +cat > "$TARGET_DIR/composer.json" < "$TARGET_DIR/php-ini/memory-limit.ini" + +mkdir -p "$TARGET_DIR/Configuration/Testing" +cat > "$TARGET_DIR/Configuration/Testing/Settings.yaml" <<'EOF' +Neos: + Flow: + object: + # In the Testing context Flow reflects the test classes of all packages. The tests of neos/party 7.1 + # use PHPUnit 10 attributes, while Neos 8.3 runs PHPUnit 9 - skip them, we never run them anyway. + includeClasses: + 'Neos.Party': ['Neos\\Party\\(?!Tests\\).*'] +EOF + +cd "$TARGET_DIR" +composer update --no-interaction --no-progress diff --git a/composer.json b/composer.json index 4ed6277..aa92689 100755 --- a/composer.json +++ b/composer.json @@ -14,6 +14,11 @@ "Flowpack\\Listable\\": "Classes" } }, + "autoload-dev": { + "psr-4": { + "Flowpack\\Listable\\Tests\\": "Tests" + } + }, "extra": { "applied-flow-migrations": [ "TYPO3.FLOW3-201201261636", From 985a7881ae2dbb8ccd130b2baa5a25f6055f03b6 Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 14:52:37 +0100 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=99=88=20ADD=20.idea=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml From 5d5c0f1242b17d60cf46a6e20f198d4ced70b3eb Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 14:54:18 +0100 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20BUGFIX:=20Always=20link=20fi?= =?UTF-8?q?rst=20and=20last=20page=20in=20pagination?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first page was only prepended if the displayed range started after page 2, the last page only appended if it ended before the second to last page. With maximumNumberOfLinks = 5, page 3 rendered '2 3 4 ... 10' without a link to page 1, page 8 rendered '1 ... 7 8 9' without page 10. Now the first/last page is added whenever it is outside the displayed range, and the '...' separator only if there is an actual gap. --- .../Fusion/PaginationArrayImplementation.php | 14 +- .../Functional/Fusion/PaginationArrayTest.php | 300 +++++++++++++++--- 2 files changed, 262 insertions(+), 52 deletions(-) diff --git a/Classes/Fusion/PaginationArrayImplementation.php b/Classes/Fusion/PaginationArrayImplementation.php index c7642f4..72420d7 100644 --- a/Classes/Fusion/PaginationArrayImplementation.php +++ b/Classes/Fusion/PaginationArrayImplementation.php @@ -19,7 +19,7 @@ public function evaluate(): array if ($totalCount > 0 !== true) { return []; } - $numberOfPages = ceil($totalCount / $itemsPerPage); + $numberOfPages = (int)ceil($totalCount / $itemsPerPage); if ($maximumNumberOfLinks > $numberOfPages) { $maximumNumberOfLinks = $numberOfPages; } @@ -35,12 +35,16 @@ public function evaluate(): array $displayRangeStart = (integer)max($displayRangeStart, 1); $displayRangeEnd = (integer)min($displayRangeEnd, $numberOfPages); $links = \range($displayRangeStart, $displayRangeEnd); - if ($displayRangeStart > 2) { - array_unshift($links, '...'); + if ($displayRangeStart > 1) { + if ($displayRangeStart > 2) { + array_unshift($links, '...'); + } array_unshift($links, 1); } - if ($displayRangeEnd + 1 < $numberOfPages) { - $links[] = '...'; + if ($displayRangeEnd < $numberOfPages) { + if ($displayRangeEnd + 1 < $numberOfPages) { + $links[] = '...'; + } $links[] = $numberOfPages; } diff --git a/Tests/Functional/Fusion/PaginationArrayTest.php b/Tests/Functional/Fusion/PaginationArrayTest.php index 10be5cb..72f8f72 100644 --- a/Tests/Functional/Fusion/PaginationArrayTest.php +++ b/Tests/Functional/Fusion/PaginationArrayTest.php @@ -8,88 +8,294 @@ class PaginationArrayTest extends AbstractFusionTestCase { /** - * @return array}> - * currentPage, numberOfPages, maximumNumberOfLinks, itemsPerPage, showPreviousNextLinks, expected links + * @test */ - public function paginationDataProvider(): array + public function firstPage(): void { - return [ - 'first page' => [1, 10, 5, 10, false, [1, 2, 3, '...', 10]], - 'middle page with gaps on both sides' => [5, 10, 5, 10, false, [1, '...', 4, 5, 6, '...', 10]], - 'last page' => [10, 10, 5, 10, false, [1, '...', 8, 9, 10]], - 'fewer pages than links' => [2, 3, 5, 10, false, [1, 2, 3]], - 'single page' => [1, 1, 5, 10, false, [1]], - 'previous and next links on a middle page' => [5, 10, 5, 10, true, ['previous', 1, '...', 4, 5, 6, '...', 10, 'next']], - 'no previous link on the first page' => [1, 10, 5, 10, true, [1, 2, 3, '...', 10, 'next']], - 'no next link on the last page' => [10, 10, 5, 10, true, ['previous', 1, '...', 8, 9, 10]], - ]; + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 100, + currentPage: 1, + + // expected + expectedLinks: [1, 2, 3, '...', 10] + ); } /** * @test - * @dataProvider paginationDataProvider - * @param array $expectedLinks */ - public function paginationArrayContainsExpectedLinks( - int $currentPage, - int $numberOfPages, - int $maximumNumberOfLinks, - int $itemsPerPage, - bool $showPreviousNextLinks, - array $expectedLinks - ): void { - $links = $this->evaluatePaginationArray( - $currentPage, - $numberOfPages * $itemsPerPage, - $maximumNumberOfLinks, - $itemsPerPage, - $showPreviousNextLinks + public function middlePageWithGapsOnBothSides(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 100, + currentPage: 5, + + // expected + expectedLinks: [1, '...', 4, 5, 6, '...', 10] + ); + } + + /** + * @test + */ + public function firstPageIsLinkedWithoutSeparatorWhenTheRangeStartsAtPageTwo(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 100, + currentPage: 3, + + // expected + expectedLinks: [1, 2, 3, 4, '...', 10] + ); + } + + /** + * @test + */ + public function lastPageIsLinkedWithoutSeparatorWhenTheRangeEndsAtTheSecondToLastPage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 100, + currentPage: 8, + + // expected + expectedLinks: [1, '...', 7, 8, 9, 10] ); + } - // compared as strings, the way they are rendered: the last page is computed with ceil() and is a float - self::assertSame(self::toStrings($expectedLinks), self::toStrings($links)); + /** + * @test + */ + public function lastPage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 100, + currentPage: 10, + + // expected + expectedLinks: [1, '...', 8, 9, 10] + ); } /** * @test */ - public function paginationArrayIsEmptyWithoutItems(): void + public function partiallyFilledLastPageCountsAsPage(): void { - self::assertSame([], $this->evaluatePaginationArray(1, 0, 5, 10, false)); + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 95, + currentPage: 1, + + // expected + expectedLinks: [1, 2, 3, '...', 10] + ); } /** - * @param array $links - * @return array + * @test */ - private static function toStrings(array $links): array + public function fewerPagesThanLinks(): void { - return array_map(static fn ($link): string => (string)$link, $links); + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 30, + currentPage: 2, + + // expected + expectedLinks: [1, 2, 3] + ); } /** - * @return array + * @test */ - private function evaluatePaginationArray( - int $currentPage, - int $totalCount, - int $maximumNumberOfLinks, + public function singlePage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 10, + currentPage: 1, + + // expected + expectedLinks: [1] + ); + } + + /** + * @test + */ + public function noLinksWithoutItems(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: false, + + // state + totalCount: 0, + currentPage: 1, + + // expected + expectedLinks: [] + ); + } + + /** + * @test + */ + public function previousAndNextLinksOnAMiddlePage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: true, + + // state + totalCount: 100, + currentPage: 5, + + // expected + expectedLinks: ['previous', 1, '...', 4, 5, 6, '...', 10, 'next'] + ); + } + + /** + * @test + */ + public function previousLinkStaysInFrontOfTheFirstPageLink(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: true, + + // state + totalCount: 100, + currentPage: 3, + + // expected + expectedLinks: ['previous', 1, 2, 3, 4, '...', 10, 'next'] + ); + } + + /** + * @test + */ + public function noPreviousLinkOnTheFirstPage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: true, + + // state + totalCount: 100, + currentPage: 1, + + // expected + expectedLinks: [1, 2, 3, '...', 10, 'next'] + ); + } + + /** + * @test + */ + public function noNextLinkOnTheLastPage(): void + { + $this->assertPaginationLinks( + // settings + itemsPerPage: 10, + maximumNumberOfLinks: 5, + showPreviousNextLinks: true, + + // state + totalCount: 100, + currentPage: 10, + + // expected + expectedLinks: ['previous', 1, '...', 8, 9, 10] + ); + } + + /** + * @param array $expectedLinks + */ + private function assertPaginationLinks( + // settings int $itemsPerPage, - bool $showPreviousNextLinks - ): array { - return $this->evaluateFusion('pagination', sprintf( + int $maximumNumberOfLinks, + bool $showPreviousNextLinks, + // state + int $totalCount, + int $currentPage, + // expected + array $expectedLinks + ): void { + $links = $this->evaluateFusion('pagination', sprintf( 'pagination = Flowpack.Listable:PaginationArray { currentPage = %d totalCount = %d - maximumNumberOfLinks = %d itemsPerPage = %d + maximumNumberOfLinks = %d showPreviousNextLinks = %s }', $currentPage, $totalCount, - $maximumNumberOfLinks, $itemsPerPage, + $maximumNumberOfLinks, $showPreviousNextLinks ? 'true' : 'false' )); + + self::assertSame($expectedLinks, $links); } } From 6bb081d42f8542c2a57e4b0d02de3c57d60a3762 Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 16:17:05 +0100 Subject: [PATCH 4/6] TASK: Ignore IDE settings --- .gitignore | 2 ++ .idea/.gitignore | 10 ---------- 2 files changed, 2 insertions(+), 10 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..403744e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# IDE settings +.idea/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 30cf57e..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Ignored default folder with query files -/queries/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml From a3486646bf7cf887cf6b931ee132c3f33ee74a4b Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 16:18:41 +0100 Subject: [PATCH 5/6] TASK: Run functional tests against Neos 9 - the test distribution installs Neos 9 (NEOS_VERSION, default 9.2), including the content graph adapter and Neos UI like the base distribution - AbstractFusionTestCase builds the Fusion runtime from FusionGlobals - tests use PHPUnit 11 attributes - CI runs Neos 9.0 on PHP 8.2 and Neos 9.2 on PHP 8.4 - README: versioning scheme table --- .github/workflows/tests.yml | 15 ++++-- README.md | 15 +++++- .../Fusion/AbstractFusionTestCase.php | 19 ++----- .../Functional/Fusion/PaginationArrayTest.php | 54 ++++++------------- Tests/Functional/run-tests.sh | 6 ++- Tests/Functional/setup-test-distribution.sh | 33 +++++------- 6 files changed, 63 insertions(+), 79 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66695b2..4a681c2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,13 +11,18 @@ concurrency: jobs: functional-tests: - name: Functional tests (PHP ${{ matrix.php-version }}, Neos 8.3) + name: Functional tests (Neos ${{ matrix.neos-version }}, PHP ${{ matrix.php-version }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php-version: [ '8.2', '8.3' ] + # the lowest and the newest supported Neos 9 line, each with its minimum PHP version + include: + - neos-version: '9.0' + php-version: '8.2' + - neos-version: '9.2' + php-version: '8.4' steps: - uses: actions/checkout@v4 @@ -36,9 +41,11 @@ jobs: - uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ runner.os }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'Tests/Functional/setup-test-distribution.sh') }} - restore-keys: composer-${{ runner.os }}-php${{ matrix.php-version }}- + key: composer-${{ runner.os }}-neos${{ matrix.neos-version }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'Tests/Functional/setup-test-distribution.sh') }} + restore-keys: composer-${{ runner.os }}-neos${{ matrix.neos-version }}-php${{ matrix.php-version }}- - name: Run functional tests # builds a throwaway Neos distribution with this package symlinked into it, see the script run: Tests/Functional/run-tests.sh "$RUNNER_TEMP/test-distribution" + env: + NEOS_VERSION: ${{ matrix.neos-version }} diff --git a/README.md b/README.md index d342c14..a08fe76 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,15 @@ The idea is very simple: you often need to display list of things (e.g. news, ar 5. For each of your nodetypes create a new Fusion object of type NodeTypeName + '.Short', or manually define a rendering object. 6. Rely on public API keys when overriding settings. +# Versioning scheme + +| Package Version | Branch | Neos / Flow Version | PHP Version | Supported | Remarks | +|-----------------------------|--------|---------------------|-------------|-----------|-----------------------------------------------------------------| +| 4.x (current `main` branch) | `main` | 9.x | >= 8.2 | ☑️ | Neos 9 / new Content Repository. | +| 3.6.x | `3.6` | 3.3 – 8.x | | ☑️ | Bugfixes for Neos 8 (and older) installations. | +| 3.0 – 3.5 | | 3.x – 7.x | | ⛔️ | Superseded by 3.6.x. | +| 2.x and older | | 3.x and older | | ⛔️ | | + # Fusion objects Keys documented here are considered public API and would be treated with semantic versioning in mind. Extend all other properties at your own risk. @@ -166,5 +175,9 @@ afterwards: # custom distribution directory and additional PHPUnit arguments Tests/Functional/run-tests.sh /tmp/listable-tests -- --filter PaginationArrayTest + # another Neos 9 minor version (default: 9.2) + NEOS_VERSION=9.0 Tests/Functional/run-tests.sh + Delete the distribution directory to start from scratch. The same script runs in the GitHub CI -(`.github/workflows/tests.yml`). +(`.github/workflows/tests.yml`), against the lowest and the newest supported Neos version. The `3.6` branch has +the same setup for Neos 8.3. diff --git a/Tests/Functional/Fusion/AbstractFusionTestCase.php b/Tests/Functional/Fusion/AbstractFusionTestCase.php index 2515dbc..5975f9d 100644 --- a/Tests/Functional/Fusion/AbstractFusionTestCase.php +++ b/Tests/Functional/Fusion/AbstractFusionTestCase.php @@ -2,11 +2,8 @@ namespace Flowpack\Listable\Tests\Functional\Fusion; use Neos\Flow\Mvc\ActionRequest; -use Neos\Flow\Mvc\ActionResponse; -use Neos\Flow\Mvc\Controller\Arguments; -use Neos\Flow\Mvc\Controller\ControllerContext; -use Neos\Flow\Mvc\Routing\UriBuilder; use Neos\Flow\Tests\FunctionalTestCase; +use Neos\Fusion\Core\FusionGlobals; use Neos\Fusion\Core\FusionSourceCodeCollection; use Neos\Fusion\Core\RuntimeFactory; use Psr\Http\Message\ServerRequestFactoryInterface; @@ -25,10 +22,8 @@ abstract class AbstractFusionTestCase extends FunctionalTestCase /** * Evaluates the Fusion path $fusionPath, defined in $fusionSourceCode, with this package's Fusion loaded. - * - * @return mixed */ - protected function evaluateFusion(string $fusionPath, string $fusionSourceCode) + protected function evaluateFusion(string $fusionPath, string $fusionSourceCode): mixed { $sourceCode = FusionSourceCodeCollection::empty(); foreach (static::FUSION_FILES as $fusionFile) { @@ -37,20 +32,16 @@ protected function evaluateFusion(string $fusionPath, string $fusionSourceCode) $sourceCode = $sourceCode->union(FusionSourceCodeCollection::fromString($fusionSourceCode)); $runtime = $this->objectManager->get(RuntimeFactory::class) - ->createFromSourceCode($sourceCode, $this->buildControllerContext()); + ->createFromSourceCode($sourceCode, FusionGlobals::fromArray(['request' => $this->buildActionRequest()])); return $runtime->evaluate($fusionPath); } - private function buildControllerContext(): ControllerContext + private function buildActionRequest(): ActionRequest { $httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class) ->createServerRequest('GET', 'http://localhost/'); - $request = ActionRequest::fromHttpRequest($httpRequest); - $uriBuilder = new UriBuilder(); - $uriBuilder->setRequest($request); - - return new ControllerContext($request, new ActionResponse(), new Arguments([]), $uriBuilder); + return ActionRequest::fromHttpRequest($httpRequest); } } diff --git a/Tests/Functional/Fusion/PaginationArrayTest.php b/Tests/Functional/Fusion/PaginationArrayTest.php index 72f8f72..cb75657 100644 --- a/Tests/Functional/Fusion/PaginationArrayTest.php +++ b/Tests/Functional/Fusion/PaginationArrayTest.php @@ -1,15 +1,15 @@ assertPaginationLinks( @@ -27,9 +27,7 @@ public function firstPage(): void ); } - /** - * @test - */ + #[Test] public function middlePageWithGapsOnBothSides(): void { $this->assertPaginationLinks( @@ -47,9 +45,7 @@ public function middlePageWithGapsOnBothSides(): void ); } - /** - * @test - */ + #[Test] public function firstPageIsLinkedWithoutSeparatorWhenTheRangeStartsAtPageTwo(): void { $this->assertPaginationLinks( @@ -67,9 +63,7 @@ public function firstPageIsLinkedWithoutSeparatorWhenTheRangeStartsAtPageTwo(): ); } - /** - * @test - */ + #[Test] public function lastPageIsLinkedWithoutSeparatorWhenTheRangeEndsAtTheSecondToLastPage(): void { $this->assertPaginationLinks( @@ -87,9 +81,7 @@ public function lastPageIsLinkedWithoutSeparatorWhenTheRangeEndsAtTheSecondToLas ); } - /** - * @test - */ + #[Test] public function lastPage(): void { $this->assertPaginationLinks( @@ -107,9 +99,7 @@ public function lastPage(): void ); } - /** - * @test - */ + #[Test] public function partiallyFilledLastPageCountsAsPage(): void { $this->assertPaginationLinks( @@ -127,9 +117,7 @@ public function partiallyFilledLastPageCountsAsPage(): void ); } - /** - * @test - */ + #[Test] public function fewerPagesThanLinks(): void { $this->assertPaginationLinks( @@ -147,9 +135,7 @@ public function fewerPagesThanLinks(): void ); } - /** - * @test - */ + #[Test] public function singlePage(): void { $this->assertPaginationLinks( @@ -167,9 +153,7 @@ public function singlePage(): void ); } - /** - * @test - */ + #[Test] public function noLinksWithoutItems(): void { $this->assertPaginationLinks( @@ -187,9 +171,7 @@ public function noLinksWithoutItems(): void ); } - /** - * @test - */ + #[Test] public function previousAndNextLinksOnAMiddlePage(): void { $this->assertPaginationLinks( @@ -207,9 +189,7 @@ public function previousAndNextLinksOnAMiddlePage(): void ); } - /** - * @test - */ + #[Test] public function previousLinkStaysInFrontOfTheFirstPageLink(): void { $this->assertPaginationLinks( @@ -227,9 +207,7 @@ public function previousLinkStaysInFrontOfTheFirstPageLink(): void ); } - /** - * @test - */ + #[Test] public function noPreviousLinkOnTheFirstPage(): void { $this->assertPaginationLinks( @@ -247,9 +225,7 @@ public function noPreviousLinkOnTheFirstPage(): void ); } - /** - * @test - */ + #[Test] public function noNextLinkOnTheLastPage(): void { $this->assertPaginationLinks( diff --git a/Tests/Functional/run-tests.sh b/Tests/Functional/run-tests.sh index f0cfeaf..b1fd925 100755 --- a/Tests/Functional/run-tests.sh +++ b/Tests/Functional/run-tests.sh @@ -2,7 +2,7 @@ # # Runs the functional tests of this package in a throwaway Neos distribution. # -# Usage: Tests/Functional/run-tests.sh [target-directory] [-- additional phpunit arguments] +# Usage: [NEOS_VERSION=9.2] Tests/Functional/run-tests.sh [target-directory] [-- additional phpunit arguments] # # The distribution is created on the first run (see setup-test-distribution.sh) and reused afterwards. # Delete the target directory to start from scratch. @@ -10,10 +10,12 @@ # Examples: # Tests/Functional/run-tests.sh # Tests/Functional/run-tests.sh /tmp/listable-tests -- --filter PaginationArrayTest +# NEOS_VERSION=9.0 Tests/Functional/run-tests.sh set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -TARGET_DIR="${TMPDIR:-/tmp}/flowpack-listable-test-distribution" +export NEOS_VERSION="${NEOS_VERSION:-9.2}" +TARGET_DIR="${TMPDIR:-/tmp}/flowpack-listable-test-distribution-neos-$NEOS_VERSION" if [[ $# -gt 0 && "$1" != "--" ]]; then TARGET_DIR="$1" shift diff --git a/Tests/Functional/setup-test-distribution.sh b/Tests/Functional/setup-test-distribution.sh index e1b41b0..d34bd64 100755 --- a/Tests/Functional/setup-test-distribution.sh +++ b/Tests/Functional/setup-test-distribution.sh @@ -5,13 +5,17 @@ # Functional tests boot a full Flow application, so they can't run from the package root alone. # Used by run-tests.sh and the GitHub CI (.github/workflows/tests.yml). # -# Usage: Tests/Functional/setup-test-distribution.sh [target-directory] +# Usage: [NEOS_VERSION=9.2] Tests/Functional/setup-test-distribution.sh [target-directory] +# +# NEOS_VERSION is the Neos minor version to test against (default: 9.2). The CI tests the lowest and the +# newest supported one. # # The target directory must be OUTSIDE of this package: the package is symlinked into it. set -euo pipefail PACKAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -TARGET_DIR="${1:-${TMPDIR:-/tmp}/flowpack-listable-test-distribution}" +NEOS_VERSION="${NEOS_VERSION:-9.2}" +TARGET_DIR="${1:-${TMPDIR:-/tmp}/flowpack-listable-test-distribution-neos-$NEOS_VERSION}" TARGET_DIR="${TARGET_DIR%/}" case "$TARGET_DIR/" in @@ -36,19 +40,21 @@ cat > "$TARGET_DIR/composer.json" < "$TARGET_DIR/php-ini/memory-limit.ini" -mkdir -p "$TARGET_DIR/Configuration/Testing" -cat > "$TARGET_DIR/Configuration/Testing/Settings.yaml" <<'EOF' -Neos: - Flow: - object: - # In the Testing context Flow reflects the test classes of all packages. The tests of neos/party 7.1 - # use PHPUnit 10 attributes, while Neos 8.3 runs PHPUnit 9 - skip them, we never run them anyway. - includeClasses: - 'Neos.Party': ['Neos\\Party\\(?!Tests\\).*'] -EOF - cd "$TARGET_DIR" composer update --no-interaction --no-progress From 58b7bff3a10a7e151bf5dd4b74e85fd9e4e36fe9 Mon Sep 17 00:00:00 2001 From: Tobias Gruber Date: Tue, 17 Nov 2026 16:30:37 +0100 Subject: [PATCH 6/6] TASK: Update GitHub actions to Node 24 versions --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4a681c2..c49eaff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: php-version: '8.4' steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - uses: shivammathur/setup-php@v2 with: @@ -38,7 +38,7 @@ jobs: id: composer-cache run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - - uses: actions/cache@v4 + - uses: actions/cache@v6 with: path: ${{ steps.composer-cache.outputs.dir }} key: composer-${{ runner.os }}-neos${{ matrix.neos-version }}-php${{ matrix.php-version }}-${{ hashFiles('composer.json', 'Tests/Functional/setup-test-distribution.sh') }}