Skip to content

Commit

Permalink
Merge pull request #2 from andreaswolf/ci-pipeline
Browse files Browse the repository at this point in the history
Add end-to-end tests
  • Loading branch information
sabbelasichon authored Apr 8, 2024
2 parents 1bf2a64 + 9270401 commit 3007e96
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint_test_pull_requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/composer.lock
/vendor/

/*/output/
25 changes: 25 additions & 0 deletions tests/composer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
24 changes: 24 additions & 0 deletions tests/run-test.sh
Original file line number Diff line number Diff line change
@@ -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/
18 changes: 18 additions & 0 deletions tests/typo3-flexform/expected-output/FlexFormWithSelect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<type>array</type>
<el>
<foo>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
</config>
</foo>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
18 changes: 18 additions & 0 deletions tests/typo3-flexform/fixtures/FlexFormWithSelect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<type>array</type>
<el>
<foo>
<config>
<type>select</type>
<maxitems>1</maxitems>
</config>
</foo>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
19 changes: 19 additions & 0 deletions tests/typo3-flexform/fractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use a9f\Fractor\Configuration\FractorConfig;
use a9f\Fractor\Fractor\DummyRule;
use a9f\FractorXml\XmlFileProcessor;
use a9f\Typo3Fractor\Rules\FlexForm\AddRenderTypeToFlexFormFractor;

return static function (FractorConfig $config) {
$config->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);
};

0 comments on commit 3007e96

Please sign in to comment.