diff --git a/.github/workflows/lint_test_pull_requests.yaml b/.github/workflows/lint_test_pull_requests.yaml index ba7034b8..3bdb25da 100644 --- a/.github/workflows/lint_test_pull_requests.yaml +++ b/.github/workflows/lint_test_pull_requests.yaml @@ -46,3 +46,20 @@ jobs: container_workdir: /app/${{ matrix.directory }} command: ${{ matrix.composer-command.command }} memory_limit: 512M + + tests: + runs-on: ubuntu-latest + name: End to end tests + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + + - name: Run tests + working-directory: tests + run: ./run-test.sh \ No newline at end of file diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..8d152d48 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/vendor/ + +/*/output/ \ No newline at end of file diff --git a/tests/composer.json b/tests/composer.json new file mode 100644 index 00000000..bf6b7cf7 --- /dev/null +++ b/tests/composer.json @@ -0,0 +1,25 @@ +{ + "name": "a9f/fractor-tests-typo3-flexform", + "type": "project", + "require": { + "a9f/fractor": "@dev", + "a9f/fractor-extension-installer": "@dev", + "a9f/fractor-xml": "@dev", + "a9f/typo3-fractor": "@dev" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.42" + }, + "repositories": { + "fractor": { + "type": "path", + "url": "../*" + } + }, + "config": { + "allow-plugins": { + "a9f/fractor-extension-installer": true, + "ergebnis/composer-normalize": true + } + } +} diff --git a/tests/run-test.sh b/tests/run-test.sh new file mode 100755 index 00000000..6fbdf159 --- /dev/null +++ b/tests/run-test.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -x + +TESTS_BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd)" +BASE_DIR="$TESTS_BASE_DIR/../" + +cd $TESTS_BASE_DIR + +rm -r composer.lock vendor || true +composer install + +TEST_DIR=typo3-flexform + +cd $TEST_DIR + +[[ -d ./output/ ]] && rm -rf ./output/ +cp -r fixtures/ output/ + +cd $TESTS_BASE_DIR +./vendor/bin/fractor process -c $TESTS_BASE_DIR/$TEST_DIR/fractor.php + +# TODO remove -b once we keep the output format when re-writing the file +diff -rub $TEST_DIR/expected-output/ $TEST_DIR/output/ diff --git a/tests/typo3-flexform/expected-output/FlexFormWithSelect.xml b/tests/typo3-flexform/expected-output/FlexFormWithSelect.xml new file mode 100644 index 00000000..d441be59 --- /dev/null +++ b/tests/typo3-flexform/expected-output/FlexFormWithSelect.xml @@ -0,0 +1,18 @@ + + + + + + array + + + + select + selectSingle + + + + + + + diff --git a/tests/typo3-flexform/fixtures/FlexFormWithSelect.xml b/tests/typo3-flexform/fixtures/FlexFormWithSelect.xml new file mode 100644 index 00000000..fb071d8d --- /dev/null +++ b/tests/typo3-flexform/fixtures/FlexFormWithSelect.xml @@ -0,0 +1,18 @@ + + + + + + array + + + + select + 1 + + + + + + + \ No newline at end of file diff --git a/tests/typo3-flexform/fractor.php b/tests/typo3-flexform/fractor.php new file mode 100644 index 00000000..126c6ea8 --- /dev/null +++ b/tests/typo3-flexform/fractor.php @@ -0,0 +1,19 @@ +import(__DIR__ . '/../vendor/a9f/fractor-xml/config/fractor.php'); + + $config->setPaths([ + __DIR__ . '/output/', + ]); + + $config->withFileProcessor(XmlFileProcessor::class); + + $config->withRule(AddRenderTypeToFlexFormFractor::class); + $config->withRule(DummyRule::class); +};