From 543f263752fe4056c69230714813bc31d58228ce Mon Sep 17 00:00:00 2001 From: mikolaj Date: Wed, 13 Mar 2024 15:41:39 +0100 Subject: [PATCH] Added test for translation extraction --- .github/actions/composer-install/action.yaml | 14 ++++++ .github/workflows/ci.yaml | 51 +++++++++++++++----- composer.json | 6 ++- phpunit.integration.xml.dist | 17 +++++++ phpunit.xml.dist | 3 -- tests/bootstrap.php | 22 +++++++++ tests/integration/Kernel.php | 30 ++++++++++++ tests/integration/Resources/config.yaml | 2 + tests/integration/TranslationTest.php | 19 ++++++++ 9 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 .github/actions/composer-install/action.yaml create mode 100644 phpunit.integration.xml.dist create mode 100644 tests/bootstrap.php create mode 100644 tests/integration/Kernel.php create mode 100644 tests/integration/Resources/config.yaml create mode 100644 tests/integration/TranslationTest.php diff --git a/.github/actions/composer-install/action.yaml b/.github/actions/composer-install/action.yaml new file mode 100644 index 00000000..0764f443 --- /dev/null +++ b/.github/actions/composer-install/action.yaml @@ -0,0 +1,14 @@ +name: 'Install Composer dependencies' +description: 'Set Composer root version from branch alias and install dependencies' +runs: + using: "composite" + steps: + - run: | + version=$(jq -r '.extra | ."branch-alias" | ."dev-main"' < composer.json) + echo "version=$version" >> $GITHUB_ENV + shell: bash + - uses: ramsey/composer-install@v2 + with: + dependency-versions: "highest" + env: + COMPOSER_ROOT_VERSION: ${{ env.version }} \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 11a80ac7..d9fbe98b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,13 +10,13 @@ on: jobs: cs-fix: name: Run code style check - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" strategy: matrix: php: - '8.0' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP Action uses: shivammathur/setup-php@v2 @@ -26,16 +26,14 @@ jobs: extensions: 'pdo_sqlite, gd' tools: cs2pr - - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "highest" + - uses: ./.github/actions/composer-install - name: Run code style check run: composer run-script check-cs -- --format=checkstyle | cs2pr tests: name: Unit tests - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" timeout-minutes: 15 strategy: @@ -44,10 +42,10 @@ jobs: php: - '7.4' - '8.0' - - '8.1' + - '8.3' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP Action uses: shivammathur/setup-php@v2 @@ -57,12 +55,43 @@ jobs: extensions: pdo_sqlite, gd tools: cs2pr - - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "highest" + - uses: ./.github/actions/composer-install - name: Setup problem matchers for PHPUnit run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run unit test suite run: composer test + + integration-tests: + name: Runs integration tests + runs-on: "ubuntu-22.04" + needs: tests + timeout-minutes: 15 + + strategy: + fail-fast: false + matrix: + php: + - '7.4' + - '8.0' + - '8.3' + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP Action + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + extensions: pdo_sqlite, gd + tools: cs2pr + + - uses: ./.github/actions/composer-install + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Run unit test suite + run: composer run-script test-integration diff --git a/composer.json b/composer.json index 2395f39f..a4aa2053 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,8 @@ "ibexa/doctrine-schema": "~4.6.0@dev", "ibexa/http-cache": "~4.6.0@dev", "ibexa/rest": "~4.6.0@dev", + "ibexa/test-core": "^4.6.x-dev", + "ibexa/user": "^4.6.x-dev", "phpunit/phpunit": "^8.2", "matthiasnoback/symfony-dependency-injection-test": "^4.0", "behat/behat": "^3.5", @@ -51,6 +53,7 @@ "EzSystems\\EzPlatformContentForms\\Tests\\": "tests/lib/", "EzSystems\\EzPlatformContentFormsBundle\\Tests\\": "tests/bundle/", "Ibexa\\Tests\\Bundle\\ContentForms\\": "tests/bundle/", + "Ibexa\\Tests\\Integration\\ContentForms\\": "tests/integration/", "Ibexa\\Tests\\ContentForms\\": "tests/lib/" } }, @@ -67,6 +70,7 @@ "scripts": { "fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots", "check-cs": "@fix-cs --dry-run", - "test": "phpunit -c phpunit.xml.dist" + "test": "phpunit -c phpunit.xml.dist", + "test-integration": "phpunit -c phpunit.integration.xml.dist" } } diff --git a/phpunit.integration.xml.dist b/phpunit.integration.xml.dist new file mode 100644 index 00000000..b9a31236 --- /dev/null +++ b/phpunit.integration.xml.dist @@ -0,0 +1,17 @@ + + + + + + + + tests/integration + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 29620047..0b1301f8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,9 +16,6 @@ ./tests/bundle - - ./tests/ - diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 00000000..60553f0b --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,22 @@ +boot(); + +$application = new Application($kernel); +$application->setAutoExit(false); + +$kernel->shutdown(); diff --git a/tests/integration/Kernel.php b/tests/integration/Kernel.php new file mode 100644 index 00000000..cd9309b7 --- /dev/null +++ b/tests/integration/Kernel.php @@ -0,0 +1,30 @@ +load(__DIR__ . '/Resources/config.yaml'); + } +} diff --git a/tests/integration/Resources/config.yaml b/tests/integration/Resources/config.yaml new file mode 100644 index 00000000..9b187c33 --- /dev/null +++ b/tests/integration/Resources/config.yaml @@ -0,0 +1,2 @@ +parameters: + locale_fallback: en diff --git a/tests/integration/TranslationTest.php b/tests/integration/TranslationTest.php new file mode 100644 index 00000000..2b40c031 --- /dev/null +++ b/tests/integration/TranslationTest.php @@ -0,0 +1,19 @@ +