-
Notifications
You must be signed in to change notification settings - Fork 378
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
Defaults to service id over names #1486
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,7 +145,11 @@ public function testAddLoaders(): void | |
*/ | ||
protected function createContainerBuilderMock() | ||
{ | ||
return $this->createObjectMock(ContainerBuilder::class, [], false); | ||
return $this->createObjectMock(ContainerBuilder::class, [ | ||
'getExtension', | ||
'addCompilerPass', | ||
'registerForAutoconfiguration', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in #1558 i kill the we could also make it a normal mock and expect the registerForAutoConfiguration method to be called and return either a mock definition or an empty real definition (in the test that actually uses this). then we can even expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not used to mock things in test. Can I have some guidance ? I'm not exactly sure how to fix the issue. I could re-target 3.x but I think those changes are worth in 2.x. |
||
], false); | ||
} | ||
|
||
/** | ||
|
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 is only available since 5.3 - can you check the symfony version before calling it?
the 5.4 build and lowest version builds fail - not sure if they install a too old symfony or if there is something else as well that we need to do for the test to work on legacy versions.
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'd also be ok to only do it with symfony 6 or 7 and otherwise skip.
the doc should mention from what symfony version on this works.
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 update the code to check if the function exists and updated the doc too.
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.
Well actually it looks like this was introduced a while ago looking at this commit symfony/symfony@18627bf
But here it is returning
null
which is rather strange as the first implementation always return aSymfony\Component\DependencyInjection\ChildDefinition
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.
Oh okay, this is because we are using a MockObject in place of a real container in the test.
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 revert my changes and add the method to the mock which should fix the tests.
Note that the
setMethods
mock method is removed from PHPUnit sebastianbergmann/phpunit#3687 (comment). Also I'm wondering why we have to create such mocks at first I think we can rely on theContainerBuilder
directly (like in https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php)