-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Translation] Rework PhpAstExtractor tests organization for future improvements
#60854
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
base: 8.1
Are you sure you want to change the base?
[Translation] Rework PhpAstExtractor tests organization for future improvements
#60854
Conversation
19b3d28 to
2ed841f
Compare
src/Symfony/Component/Translation/Tests/Extractor/Visitor/AbstractVisitorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Translation/Tests/Extractor/Visitor/AbstractVisitorTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Translation/Tests/Extractor/Visitor/ConstraintVisitorTest.php
Outdated
Show resolved
Hide resolved
...mfony/Component/Translation/Tests/Fixtures/extractor-php-ast/form-type-visitor/form-type.php
Outdated
Show resolved
Hide resolved
...mfony/Component/Translation/Tests/Fixtures/extractor-php-ast/form-type-visitor/form-type.php
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,47 @@ | |||
| This template is used for translation message extraction tests | |||
| <?php new TranslatableMessage('translatable single-quoted key'); ?> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this missing a use statement ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Also TransMethodVisitor has be updated to check the full classname.
2ed841f to
23ead95
Compare
src/Symfony/Component/Translation/Extractor/Visitor/AbstractVisitor.php
Outdated
Show resolved
Hide resolved
PhpAstExtractor tests organization for future improvements
56c8e7c to
9e34c67
Compare
src/Symfony/Component/Translation/Extractor/Visitor/TranslatableMessageVisitor.php
Show resolved
Hide resolved
src/Symfony/Component/Translation/Tests/Extractor/Visitor/AbstractVisitorTestCase.php
Outdated
Show resolved
Hide resolved
...mfony/Component/Translation/Tests/Fixtures/extractor-php-ast/form-type-visitor/form-type.php
Outdated
Show resolved
Hide resolved
| $this->assertEquals(['sources' => [self::FIXTURES_FOLDER.'translation.html.php:37']], $catalogue->getMetadata('other-domain-test-no-params-short-array', 'not_messages')); | ||
| $this->assertEquals(['sources' => [self::FIXTURES_FOLDER.'translation-73.html.php:8']], $catalogue->getMetadata("nowdoc\nindented\n further")); | ||
|
|
||
| $this->assertEquals(['sources' => [self::FIXTURES_FOLDER.'translatable-short.html.php:2']], $catalogue->getMetadata('translatable-short single-quoted key')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This misses the str_replace(\DIRECTORY_SEPARATOR, '/', __DIR__) that was present in the old test (or an equivalent) because the catalogue metadata always stores paths with / as separator instead of the real path.
That's why the CI fails on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I missed that CI fails on Windows. It's fixed.
This PR is the first in a series that tend to improve PhpAstExtractor (covering more extractions cases, ease test writting for new cases, etc).
I've worked with @Jean-Beru, @Kazadri and @jprivet-dev in the past few weeks on various new cases to increase the number of "locations" from where the extractor can extract translation keys.
As we were working on my own Symfony fork, I'm opening the PR.
But to be honest my colleague @Jean-Beru did the large majority of the work here. Thanks to him 👏!
To avoid a big PR containing multiple new small features, we need to open and hopefully merge this one first to ease the tests writting for next new Visitors.
NB: I'm not sure to qualify or not this PR as New feature?