Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for translation extraction #63

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/actions/composer-install/action.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
51 changes: 40 additions & 11 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,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:
Expand All @@ -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
Expand All @@ -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
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/"
}
},
Expand All @@ -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"
}
}
17 changes: 17 additions & 0 deletions phpunit.integration.xml.dist
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\ContentForms\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>
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<testsuite name="ContentFormsBundle tests">
<directory suffix="Test.php">./tests/bundle</directory>
</testsuite>
<testsuite name="Ibexa ContentForms tests">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>

<filter>
Expand Down
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\ContentForms\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();
30 changes: 30 additions & 0 deletions tests/integration/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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\ContentForms;

use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

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

yield new IbexaContentFormsBundle();
}

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

$loader->load(__DIR__ . '/Resources/config.yaml');
}
}
2 changes: 2 additions & 0 deletions tests/integration/Resources/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
locale_fallback: en
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\ContentForms;

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

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