Skip to content

Commit

Permalink
Added test for translation extraction (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikadamczyk authored Mar 15, 2024
1 parent 47c09b0 commit d04450b
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 9 deletions.
49 changes: 42 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -35,7 +35,7 @@ jobs:

tests:
name: Tests
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-22.04"
timeout-minutes: 10

strategy:
Expand All @@ -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
Expand All @@ -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"

Expand All @@ -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
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -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": {
Expand Down
17 changes: 17 additions & 0 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
verbose="true">
<php>
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\FieldTypeMatrix\Kernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=4&amp;max[direct]=0&amp;verbose=0"/>
</php>
<testsuites>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
</phpunit>
22 changes: 22 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

use Ibexa\Tests\Integration\FieldTypeMatrix\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

require_once dirname(__DIR__) . '/vendor/autoload.php';

chdir(dirname(__DIR__));

$kernel = new Kernel('test', true);
$kernel->boot();

$application = new Application($kernel);
$application->setAutoExit(false);

$kernel->shutdown();
70 changes: 70 additions & 0 deletions tests/integration/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Integration\FieldTypeMatrix;

use Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle;
use Ibexa\Bundle\AdminUi\IbexaAdminUiBundle;
use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle;
use Ibexa\Bundle\DesignEngine\IbexaDesignEngineBundle;
use Ibexa\Bundle\FieldTypeMatrix\IbexaFieldTypeMatrixBundle;
use Ibexa\Bundle\GraphQL\IbexaGraphQLBundle;
use Ibexa\Bundle\Notifications\IbexaNotificationsBundle;
use Ibexa\Bundle\Rest\IbexaRestBundle;
use Ibexa\Bundle\Search\IbexaSearchBundle;
use Ibexa\Bundle\User\IbexaUserBundle;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle;
use Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;

final class Kernel extends IbexaTestKernel
{
public function registerBundles(): iterable
{
yield from parent::registerBundles();

yield new LexikJWTAuthenticationBundle();
yield new HautelookTemplatedUriBundle();
yield new WebpackEncoreBundle();
yield new SwiftmailerBundle();
yield new KnpMenuBundle();

yield new IbexaRestBundle();
yield new IbexaContentFormsBundle();
yield new IbexaSearchBundle();
yield new IbexaUserBundle();
yield new IbexaDesignEngineBundle();
yield new IbexaAdminUiBundle();
yield new IbexaNotificationsBundle();
yield new IbexaGraphQLBundle();

yield new IbexaFieldTypeMatrixBundle();
}

public function registerContainerConfiguration(LoaderInterface $loader): void
{
parent::registerContainerConfiguration($loader);

$loader->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(),
],
]);
});
}
}
23 changes: 23 additions & 0 deletions tests/integration/Resources/config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tests/integration/Resources/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ibexa.user.default_profile_image.initials:
path: /user/default_profile_image/initials.svg
19 changes: 19 additions & 0 deletions tests/integration/TranslationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Integration\FieldTypeMatrix;

use Ibexa\Contracts\Test\Core\Translation\AbstractTranslationCase;

final class TranslationTest extends AbstractTranslationCase
{
public static function provideConfigNamesForTranslation(): iterable
{
yield ['ibexa_fieldtype_matrix'];
}
}

0 comments on commit d04450b

Please sign in to comment.