Skip to content

Commit 519420a

Browse files
authored
Added test for translation extraction (#63)
1 parent 90e9fe9 commit 519420a

File tree

9 files changed

+149
-15
lines changed

9 files changed

+149
-15
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: 'Install Composer dependencies'
2+
description: 'Set Composer root version from branch alias and install dependencies'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- run: |
7+
version=$(jq -r '.extra | ."branch-alias" | ."dev-main"' < composer.json)
8+
echo "version=$version" >> $GITHUB_ENV
9+
shell: bash
10+
- uses: ramsey/composer-install@v2
11+
with:
12+
dependency-versions: "highest"
13+
env:
14+
COMPOSER_ROOT_VERSION: ${{ env.version }}

.github/workflows/ci.yaml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ on:
1010
jobs:
1111
cs-fix:
1212
name: Run code style check
13-
runs-on: "ubuntu-20.04"
13+
runs-on: "ubuntu-22.04"
1414
strategy:
1515
matrix:
1616
php:
1717
- '8.0'
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
2020

2121
- name: Setup PHP Action
2222
uses: shivammathur/setup-php@v2
@@ -26,16 +26,14 @@ jobs:
2626
extensions: 'pdo_sqlite, gd'
2727
tools: cs2pr
2828

29-
- uses: "ramsey/composer-install@v1"
30-
with:
31-
dependency-versions: "highest"
29+
- uses: ./.github/actions/composer-install
3230

3331
- name: Run code style check
3432
run: composer run-script check-cs -- --format=checkstyle | cs2pr
3533

3634
tests:
3735
name: Unit tests
38-
runs-on: "ubuntu-20.04"
36+
runs-on: "ubuntu-22.04"
3937
timeout-minutes: 15
4038

4139
strategy:
@@ -44,10 +42,10 @@ jobs:
4442
php:
4543
- '7.4'
4644
- '8.0'
47-
- '8.1'
45+
- '8.3'
4846

4947
steps:
50-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
5149

5250
- name: Setup PHP Action
5351
uses: shivammathur/setup-php@v2
@@ -57,12 +55,43 @@ jobs:
5755
extensions: pdo_sqlite, gd
5856
tools: cs2pr
5957

60-
- uses: "ramsey/composer-install@v1"
61-
with:
62-
dependency-versions: "highest"
58+
- uses: ./.github/actions/composer-install
6359

6460
- name: Setup problem matchers for PHPUnit
6561
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
6662

6763
- name: Run unit test suite
6864
run: composer test
65+
66+
integration-tests:
67+
name: Runs integration tests
68+
runs-on: "ubuntu-22.04"
69+
needs: tests
70+
timeout-minutes: 15
71+
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
php:
76+
- '7.4'
77+
- '8.0'
78+
- '8.3'
79+
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Setup PHP Action
84+
uses: shivammathur/setup-php@v2
85+
with:
86+
php-version: ${{ matrix.php }}
87+
coverage: none
88+
extensions: pdo_sqlite, gd
89+
tools: cs2pr
90+
91+
- uses: ./.github/actions/composer-install
92+
93+
- name: Setup problem matchers for PHPUnit
94+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
95+
96+
- name: Run unit test suite
97+
run: composer run-script test-integration

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
"ibexa/doctrine-schema": "~4.6.0@dev",
3131
"ibexa/http-cache": "~4.6.0@dev",
3232
"ibexa/rest": "~4.6.0@dev",
33+
"ibexa/test-core": "^4.6.x-dev",
34+
"ibexa/user": "^4.6.x-dev",
3335
"phpunit/phpunit": "^8.2",
3436
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
3537
"behat/behat": "^3.5",
@@ -51,6 +53,7 @@
5153
"EzSystems\\EzPlatformContentForms\\Tests\\": "tests/lib/",
5254
"EzSystems\\EzPlatformContentFormsBundle\\Tests\\": "tests/bundle/",
5355
"Ibexa\\Tests\\Bundle\\ContentForms\\": "tests/bundle/",
56+
"Ibexa\\Tests\\Integration\\ContentForms\\": "tests/integration/",
5457
"Ibexa\\Tests\\ContentForms\\": "tests/lib/"
5558
}
5659
},
@@ -67,6 +70,7 @@
6770
"scripts": {
6871
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
6972
"check-cs": "@fix-cs --dry-run",
70-
"test": "phpunit -c phpunit.xml.dist"
73+
"test": "phpunit -c phpunit.xml.dist",
74+
"test-integration": "phpunit -c phpunit.integration.xml.dist"
7175
}
7276
}

phpunit.integration.xml.dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
3+
bootstrap="tests/bootstrap.php"
4+
beStrictAboutOutputDuringTests="true"
5+
beStrictAboutTodoAnnotatedTests="true"
6+
failOnWarning="true"
7+
verbose="true">
8+
<php>
9+
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\ContentForms\Kernel" />
10+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=4&amp;max[direct]=0&amp;verbose=0"/>
11+
</php>
12+
<testsuites>
13+
<testsuite name="integration">
14+
<directory>tests/integration</directory>
15+
</testsuite>
16+
</testsuites>
17+
</phpunit>

phpunit.xml.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<testsuite name="ContentFormsBundle tests">
1717
<directory suffix="Test.php">./tests/bundle</directory>
1818
</testsuite>
19-
<testsuite name="Ibexa ContentForms tests">
20-
<directory suffix="Test.php">./tests/</directory>
21-
</testsuite>
2219
</testsuites>
2320

2421
<filter>

tests/bootstrap.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
use Ibexa\Tests\Integration\ContentForms\Kernel;
10+
use Symfony\Bundle\FrameworkBundle\Console\Application;
11+
12+
require_once dirname(__DIR__) . '/vendor/autoload.php';
13+
14+
chdir(dirname(__DIR__));
15+
16+
$kernel = new Kernel('test', true);
17+
$kernel->boot();
18+
19+
$application = new Application($kernel);
20+
$application->setAutoExit(false);
21+
22+
$kernel->shutdown();

tests/integration/Kernel.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\ContentForms;
10+
11+
use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle;
12+
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
13+
use Symfony\Component\Config\Loader\LoaderInterface;
14+
15+
final class Kernel extends IbexaTestKernel
16+
{
17+
public function registerBundles(): iterable
18+
{
19+
yield from parent::registerBundles();
20+
21+
yield new IbexaContentFormsBundle();
22+
}
23+
24+
public function registerContainerConfiguration(LoaderInterface $loader): void
25+
{
26+
parent::registerContainerConfiguration($loader);
27+
28+
$loader->load(__DIR__ . '/Resources/config.yaml');
29+
}
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
parameters:
2+
locale_fallback: en

tests/integration/TranslationTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\ContentForms;
10+
11+
use Ibexa\Contracts\Test\Core\Translation\AbstractTranslationCase;
12+
13+
final class TranslationTest extends AbstractTranslationCase
14+
{
15+
public static function provideConfigNamesForTranslation(): iterable
16+
{
17+
yield ['ibexa_content_forms'];
18+
}
19+
}

0 commit comments

Comments
 (0)