From d04450bcc23d6db11c6f04895c824be777698fdd Mon Sep 17 00:00:00 2001 From: Mikolaj Adamczyk Date: Fri, 15 Mar 2024 12:12:57 +0100 Subject: [PATCH] Added test for translation extraction (#40) --- .github/workflows/ci.yaml | 49 ++++++++++++++--- composer.json | 7 ++- phpunit.integration.xml | 17 ++++++ tests/bootstrap.php | 22 ++++++++ tests/integration/Kernel.php | 70 ++++++++++++++++++++++++ tests/integration/Resources/config.yaml | 23 ++++++++ tests/integration/Resources/routing.yaml | 2 + tests/integration/TranslationTest.php | 19 +++++++ 8 files changed, 200 insertions(+), 9 deletions(-) create mode 100644 phpunit.integration.xml 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/Resources/routing.yaml create mode 100644 tests/integration/TranslationTest.php diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index af6e893..aace7b2 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,7 +26,7 @@ jobs: extensions: 'pdo_sqlite, gd' tools: cs2pr - - uses: "ramsey/composer-install@v1" + - uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" @@ -35,7 +35,7 @@ jobs: tests: name: Tests - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" timeout-minutes: 10 strategy: @@ -44,10 +44,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,7 +57,7 @@ jobs: extensions: pdo_sqlite, gd tools: cs2pr - - uses: "ramsey/composer-install@v1" + - uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" @@ -66,3 +66,38 @@ jobs: - name: Run test suite run: composer run-script --timeout=600 test + + integration-tests: + name: Tests + needs: tests + runs-on: "ubuntu-22.04" + timeout-minutes: 10 + + 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: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + + - name: Setup problem matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Run test suite + run: composer run-script --timeout=600 test-integration diff --git a/composer.json b/composer.json index ade1661..e4439b1 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "autoload-dev": { "psr-4": { - "Ibexa\\Tests\\FieldTypeMatrix\\": "tests/lib/" + "Ibexa\\Tests\\FieldTypeMatrix\\": "tests/lib/", + "Ibexa\\Tests\\Integration\\FieldTypeMatrix\\": "tests/integration/" } }, "require": { @@ -42,6 +43,7 @@ "ibexa/fieldtype-richtext": "~4.6.0@dev", "ibexa/search": "~4.6.0@dev", "ibexa/rest": "~4.6.0@dev", + "ibexa/test-core": "^4.6.x-dev", "ibexa/http-cache": "~4.6.0@dev", "ibexa/design-engine": "~4.6.0@dev", "ibexa/code-style": "^1.0", @@ -51,7 +53,8 @@ "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" + "test": "phpunit -c phpunit.xml", + "test-integration": "phpunit -c phpunit.integration.xml" }, "extra": { "branch-alias": { diff --git a/phpunit.integration.xml b/phpunit.integration.xml new file mode 100644 index 0000000..562d091 --- /dev/null +++ b/phpunit.integration.xml @@ -0,0 +1,17 @@ + + + + + + + + tests/integration + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..70756d5 --- /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 0000000..4eaec91 --- /dev/null +++ b/tests/integration/Kernel.php @@ -0,0 +1,70 @@ +load(__DIR__ . '/Resources/config.yaml'); + $loader->load(static function (ContainerBuilder $container): void { + $resource = new FileResource(__DIR__ . '/Resources/routing.yaml'); + $container->addResource($resource); + $container->setParameter('form.type_extension.csrf.enabled', false); + $container->loadFromExtension('framework', [ + 'router' => [ + 'resource' => $resource->getResource(), + ], + ]); + }); + } +} diff --git a/tests/integration/Resources/config.yaml b/tests/integration/Resources/config.yaml new file mode 100644 index 0000000..60ae5ec --- /dev/null +++ b/tests/integration/Resources/config.yaml @@ -0,0 +1,23 @@ +parameters: + locale_fallback: en + +webpack_encore: + # The path where Encore is building the assets - i.e. Encore.setOutputPath() + output_path: '%kernel.project_dir%/public/build' + +lexik_jwt_authentication: + secret_key: 'foo' + +ibexa: + repositories: + default: + search: + engine: '%env(SEARCH_ENGINE)%' + connection: default + + system: + default: + languages: + - eng-US + - eng-GB + - ger-DE diff --git a/tests/integration/Resources/routing.yaml b/tests/integration/Resources/routing.yaml new file mode 100644 index 0000000..2956445 --- /dev/null +++ b/tests/integration/Resources/routing.yaml @@ -0,0 +1,2 @@ +ibexa.user.default_profile_image.initials: + path: /user/default_profile_image/initials.svg diff --git a/tests/integration/TranslationTest.php b/tests/integration/TranslationTest.php new file mode 100644 index 0000000..5046f80 --- /dev/null +++ b/tests/integration/TranslationTest.php @@ -0,0 +1,19 @@ +