-
Notifications
You must be signed in to change notification settings - Fork 36
Fix #184: Check FormTypeInterface instead of class name suffix #185
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <?php | ||
|
|
||
| namespace Translation\Extractor\Tests\Functional\Visitor\Php\Symfony; | ||
|
|
||
| use Translation\Extractor\Tests\Functional\Visitor\Php\BasePHPVisitorTest; | ||
| use Translation\Extractor\Tests\Resources; | ||
| use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit; | ||
|
|
||
| class IsFormTypeTest extends BasePHPVisitorTest | ||
| { | ||
| public function testParentFormTypeExtractsTranslations(): void | ||
| { | ||
| $collection = $this->getSourceLocations( | ||
| new FormTypeLabelExplicit(), | ||
| Resources\Php\Symfony\ParentType::class | ||
| ); | ||
|
|
||
| $this->assertCount(1, $collection); | ||
| $source = $collection->first(); | ||
| $this->assertEquals('parent.field.label', $source->getMessage()); | ||
| } | ||
|
|
||
| public function testInheritedFormTypeIsProperlyDetected(): void | ||
| { | ||
| $collection = $this->getSourceLocations( | ||
| new FormTypeLabelExplicit(), | ||
| Resources\Php\Symfony\IsFormType::class | ||
| ); | ||
|
|
||
| $this->assertCount(1, $collection); | ||
| $source = $collection->first(); | ||
| $this->assertEquals('child.field.label', $source->getMessage()); | ||
| } | ||
|
|
||
| public function testNonFormTypeDoesNotExtractTranslations(): void | ||
| { | ||
| $collection = $this->getSourceLocations( | ||
| new FormTypeLabelExplicit(), | ||
| Resources\Php\Symfony\NotAFormType::class | ||
| ); | ||
|
|
||
| $this->assertCount(0, $collection); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Translation\Extractor\Tests\Resources\Php\Symfony; | ||
|
|
||
| use Symfony\Component\Form\FormBuilderInterface; | ||
|
|
||
| class IsFormType extends ParentType | ||
| { | ||
| public function buildForm(FormBuilderInterface $builder, array $options): void | ||
| { | ||
| parent::buildForm($builder, $options); | ||
|
|
||
| $builder->add('child_field', null, [ | ||
| 'label' => 'child.field.label' | ||
| ]); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hm,
extends AbstractTypeshould also work, right? I suppose we should revert it.I mean, we should check both:
extends AbstractTypeandimplements FormTypeInterfaceI see you already check for
implements FormTypeInterfacein other places, so I would prefer to revert back toextends AbstractTypein those spots where you changed to interface to make sure it's still works tooThere 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.
If i extends AbstractType i need to require dev symfony/form or create a AbstractType class that implements FormTypeInterface in test/Resources/Php/Symfony.
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.
Hm, I see.. Well, then I'm fine with using the interface. Though it would be cool to have a test that will cover the case with an extended base class like
AbstractTypeto make sure it finds that interface implemented even in the parent base class we extend. Maybe creating a custom AbstractType that implements FormTypeInterface just for test purposes would make sense 👍🏼Uh oh!
There was an error while loading. Please reload this page.
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.
I did a test, where a formType extends a parentType that implements FormTypeInterface, but if you prefer to call it AbstractType i can change the name of the parentType class
The test is : IsFormTypeTest
I made it because i needed to validate my recursive verification
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.
Ah ok, I missed that... That's good to have this test to check the recursive feature, good job 👍🏼