Skip to content

Commit

Permalink
Added translations test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikadamczyk committed Oct 31, 2023
1 parent f6b11f7 commit 5b421ba
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 13 deletions.
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"psr-4": {
"Ibexa\\Tests\\Bundle\\AdminUi\\": "tests/bundle/",
"Ibexa\\Tests\\AdminUi\\": "tests/lib/",
"Ibexa\\Tests\\Integration\\AdminUi\\": "tests/integration/",
"EzSystems\\EzPlatformAdminUi\\Tests\\": "tests/lib/",
"Ibexa\\Platform\\Tests\\Assets\\": "tests/lib/"
}
Expand Down Expand Up @@ -60,9 +61,11 @@
"willdurand/js-translation-bundle": "^4.0",
"twig/twig": "^3.0",
"twig/intl-extra": "^3.0",
"twig/string-extra": "^3.0"
"twig/string-extra": "^3.0",
"http-interop/http-factory-guzzle": "^1.2"
},
"require-dev": {
"dama/doctrine-test-bundle": "^v6.7",
"ibexa/ci-scripts": "^0.2@dev",
"ibexa/behat": "~4.6.0@dev",
"friendsofphp/php-cs-fixer": "^3.0",
Expand All @@ -71,6 +74,7 @@
"ibexa/doctrine-schema": "~4.6.0@dev",
"ibexa/http-cache": "~4.6.0@dev",
"ibexa/code-style": "^1.0",
"ibexa/test-core": "^0.1.x-dev",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-symfony": "^1.3"
Expand All @@ -84,7 +88,9 @@
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --dry-run",
"phpstan": "phpstan analyse",
"test": "phpunit -c phpunit.xml"
"test": ["@test-unit", "@test-integration"],
"test-unit": "phpunit -c phpunit.xml",
"test-integration": "phpunit -c phpunit.integration.xml"
},
"extra": {
"branch-alias": {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"repository": "[email protected]:ibexa/admin-ui.git",
"private": true,
"prettier": "eslint-config-ibexa/prettier",
"dependencies": {},
"dependencies": {
"prettier": "^3.0.3"
},
"devDependencies": {
"eslint-config-ibexa": "https://github.com/ibexa/eslint-config-ibexa.git#v1.0.0"
},
Expand Down
25 changes: 25 additions & 0 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/integration/bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnWarning="true"
colors="true">
<testsuites>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
<php>
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" />
<env name="KERNEL_CLASS" value="\Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;verbose=0"/>
</php>
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
</extensions>
</phpunit>
4 changes: 2 additions & 2 deletions src/bundle/Resources/config/services/components.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
imports:
- { resource: services/components/content/edit.yaml }
- { resource: services/components/content_type/edit.yaml }
- { resource: ../services/components/content/edit.yaml }
- { resource: ../services/components/content_type/edit.yaml }

services:
_defaults:
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
public: false

Ibexa\AdminUi\EventListener\:
resource: "../../../lib/EventListener/*"
resource: "../../../../lib/EventListener/*"
public: true
tags:
- { name: kernel.event_subscriber }
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/form_processors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
public: false

Ibexa\AdminUi\Form\Processor\:
resource: "../../../lib/Form/Processor/*"
resource: "../../../../lib/Form/Processor/*"
public: true
tags:
- { name: kernel.event_subscriber }
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/tabs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
lazy: true

Ibexa\AdminUi\Tab\Event\Subscriber\:
resource: "../../../lib/Tab/Event/Subscriber/*"
resource: "../../../../lib/Tab/Event/Subscriber/*"
public: true
tags: ['kernel.event_subscriber']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
Ibexa\AdminUi\Tab\ContentType\:
resource: "../../../lib/Tab/ContentType/*"
resource: "../../../../../lib/Tab/ContentType/*"
parent: Ibexa\Contracts\AdminUi\Tab\AbstractEventDispatchingTab
public: true
tags:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
Ibexa\AdminUi\Tab\LocationView\:
resource: "../../../lib/Tab/LocationView/*"
resource: "../../../../../lib/Tab/LocationView/*"
parent: Ibexa\Contracts\AdminUi\Tab\AbstractTab
public: true
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- { name: twig.extension }

Ibexa\AdminUi\UniversalDiscovery\Event\Subscriber\:
resource: "../../../lib/UniversalDiscovery/Event/Subscriber/*"
resource: "../../../../lib/UniversalDiscovery/Event/Subscriber/*"
public: true
tags: ['kernel.event_subscriber']

Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
public: false

Ibexa\AdminUi\Util\:
resource: "../../../lib/Util"
resource: "../../../../lib/Util"
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
public: false

Ibexa\AdminUi\Validator\Constraints\:
resource: "../../../lib/Validator/Constraints"
resource: "../../../../lib/Validator/Constraints"

Ibexa\AdminUi\Validator\Constraints\LocationIsWithinCopySubtreeLimitValidator:
arguments:
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/messages.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="4b260ae7c4bff42c0b4813dbb4e92de939f52717" resname="anchor_menu.more">
<source>More</source>
<target state="new">More</target>
<note>key: anchor_menu.more</note>
</trans-unit>
<trans-unit id="9177237415bf4199961eb8de9353011a5b22a039" resname="anchor_navigation.close">
<source>Close</source>
<target state="new">Close</target>
Expand Down
137 changes: 137 additions & 0 deletions tests/integration/AdminUiIbexaTestKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?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\AdminUi;

use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
use Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle;
use Ibexa\Bundle\AdminUi\IbexaAdminUiBundle;
use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle;
use Ibexa\Bundle\Rest\IbexaRestBundle;
use Ibexa\Bundle\Search\IbexaSearchBundle;
use Ibexa\Bundle\User\IbexaUserBundle;
use Ibexa\Contracts\Migration\Metadata\Storage\MetadataStorage;
use Ibexa\Contracts\Migration\MigrationStorage;
use Ibexa\Contracts\Test\Core\IbexaTestKernel;
use Ibexa\Migration\Metadata\Storage\InMemoryMetadataStorage;
use Ibexa\Migration\Storage\InMemoryMigrationStorage;
use Ibexa\Tests\Integration\AdminUi\DependencyInjection\Configuration\IgnoredConfigParser;
use Knp\Menu\FactoryInterface;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Swift_Mailer;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
use Symfony\WebpackEncoreBundle\Asset\TagRenderer;

/**
* @internal
*/
final class AdminUiIbexaTestKernel extends IbexaTestKernel
{
public function registerBundles(): iterable
{
yield from parent::registerBundles();

yield new IbexaRestBundle();
yield new IbexaUserBundle();
yield new IbexaAdminUiBundle();
yield new IbexaContentFormsBundle();
yield new IbexaSearchBundle();
yield new DAMADoctrineTestBundle();
yield new HautelookTemplatedUriBundle();
}

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

$loader->load(static function (ContainerBuilder $container): void {
$container->setParameter('locale_fallback', 'en');
});

$loader->load(dirname(__DIR__, 2) . '/src/bundle/Resources/config/services.yaml');

$loader->load(__DIR__ . '/Resources/ibexa.yaml');

$loader->load(static function (ContainerBuilder $container): void {
self::configureIbexaDXPBundles($container);
self::configureThirdPartyBundles($container);

self::loadRouting($container, __DIR__ . '/Resources/routing.yaml');
});
}

private static function loadRouting(ContainerBuilder $container, string $filePath): void
{
$container->loadFromExtension('framework', [
'router' => [
'resource' => $filePath,
],
]);
$container->addResource(new FileResource($filePath));
}

private static function configureIbexaDXPBundles(ContainerBuilder $container): void
{
self::configureMigrationsBundle($container);

$container->setParameter('form.type_extension.csrf.enabled', false);
$container->setParameter('ibexa.http_cache.purge_type', 'local');
$container->setParameter('ibexa.http_cache.translation_aware.enabled', false);
$container->setParameter('locale_fallback', 'en');
$container->register('fragment.renderer.esi', EsiFragmentRenderer::class);

/** @var \Ibexa\Bundle\Core\DependencyInjection\IbexaCoreExtension $kernel */
$kernel = $container->getExtension('ibexa');
$kernel->addConfigParser(
new IgnoredConfigParser(
[
'admin_ui_forms',
'calendar',
'content_create_view',
'content_translate_view',
'content_edit_view',
'design',
'search_view',
'universal_discovery_widget_module',
]
)
);
}

protected static function getExposedServicesByClass(): iterable
{
yield from parent::getExposedServicesByClass();
}

private static function configureMigrationsBundle(ContainerBuilder $container): void
{
$container->setDefinition(MetadataStorage::class, new Definition(InMemoryMetadataStorage::class));
$container->setDefinition(MigrationStorage::class, new Definition(InMemoryMigrationStorage::class));
}

private static function configureThirdPartyBundles(ContainerBuilder $container): void
{
$container->setParameter('fos_http_cache.tag_handler.strict', false);
$container->setParameter('fos_http_cache.compiler_pass.tag_annotations', false);

self::addSyntheticService($container, Swift_Mailer::class);
self::addSyntheticService($container, JWTTokenManagerInterface::class);
self::addSyntheticService($container, FactoryInterface::class);
self::addSyntheticService($container, TagRenderer::class, 'webpack_encore.tag_renderer');
self::addSyntheticService(
$container,
EntrypointLookupCollection::class,
'webpack_encore.entrypoint_lookup_collection'
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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\AdminUi\DependencyInjection\Configuration;

use Ibexa\Bundle\Core\DependencyInjection\Configuration\AbstractParser;
use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;

final class IgnoredConfigParser extends AbstractParser
{
/** @var array<string> */
private array $keys;

/**
* @param array<string> $keys
*/
public function __construct(array $keys)
{
$this->keys = $keys;
}

public function addSemanticConfig(NodeBuilder $nodeBuilder): void
{
foreach ($this->keys as $key) {
$nodeBuilder->variableNode($key)->defaultNull()->end();
}
}

/**
* @param array<string, mixed> $scopeSettings
*/
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
{
}
}
4 changes: 4 additions & 0 deletions tests/integration/Resources/ibexa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ibexa:
system:
default:
languages: [ 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:
resource: '@IbexaUserBundle/Resources/config/routing.yaml'
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\AdminUi;

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

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

0 comments on commit 5b421ba

Please sign in to comment.