Skip to content

Commit

Permalink
Add tests for enum field "enum_translation_domain" option
Browse files Browse the repository at this point in the history
  • Loading branch information
zyberspace committed Nov 13, 2024
1 parent f82eb21 commit 89953cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
D: '[trans]D[/trans]'
Diamonds: '[trans]Diamonds[/trans]'
28 changes: 28 additions & 0 deletions tests/Twig/Extension/RenderElementExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Symfony\Component\Routing\Loader\XmlFileLoader;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Translation\Loader\XliffFileLoader;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
Expand Down Expand Up @@ -79,12 +80,19 @@ protected function setUp(): void
// translation extension
$translator = new Translator('en');
$translator->addLoader('xlf', new XliffFileLoader());
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource(
'xlf',
\sprintf('%s/../../../src/Resources/translations/SonataAdminBundle.en.xliff', __DIR__),
'en',
'SonataAdminBundle'
);
$translator->addResource(
'yaml',
\sprintf('%s/../../Fixtures/Resources/translations/render-element-extension-test.en.yaml', __DIR__),
'en',
'render-element-extension-test',
);

$this->translator = $translator;

Expand Down Expand Up @@ -1551,6 +1559,26 @@ class="x-editable"
],
];

$elements[] = [
'<td class="sonata-ba-list-field sonata-ba-list-field-enum" objectId="12345"> [trans]Diamonds[/trans] </td>',
FieldDescriptionInterface::TYPE_ENUM,
Suit::Diamonds,
[
'use_value' => false,
'enum_translation_domain' => 'render-element-extension-test',
],
];

$elements[] = [
'<td class="sonata-ba-list-field sonata-ba-list-field-enum" objectId="12345"> [trans]D[/trans] </td>',
FieldDescriptionInterface::TYPE_ENUM,
Suit::Diamonds,
[
'use_value' => true,
'enum_translation_domain' => 'render-element-extension-test',
],
];

return $elements;
}

Expand Down

0 comments on commit 89953cf

Please sign in to comment.