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
Remove calls to getMockForAbstractClass()
#54745
base: 5.4
Are you sure you want to change the base?
Conversation
getMockForAbstractClass()
getMockForAbstractClass()
cab3b78
to
418acf7
Compare
src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php
Show resolved
Hide resolved
src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
Outdated
Show resolved
Hide resolved
7e24f2d
to
0aee22d
Compare
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.
Thanks. Just one failure on deps=low.
src/Symfony/Component/Routing/Tests/Loader/AbstractAnnotationLoaderTestCase.php
Outdated
Show resolved
Hide resolved
0aee22d
to
505d5a5
Compare
505d5a5
to
2cdf1ef
Compare
src/Symfony/Component/Security/Core/Tests/Authorization/Voter/TraceableVoterTest.php
Show resolved
Hide resolved
86796a8
to
11a767b
Compare
$bundle = $this | ||
->getMockBuilder(BundleInterface::class) | ||
->getMockBuilder(\get_class($bundle)) |
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.
->getMockBuilder(\get_class($bundle)) | |
->getMockBuilder($className ?? \get_class($bundle)) |
Can't we use this and remove the if
below?
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.
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.
Also I never played with setMockClassName
, but it seems that using ??
would change the semantic and the mock wouldn't implement BundleInterface
anymore. We need to implement BundleInterface
, which is done with getMockBuilder
. Then setMockClassName
would rename the mock but keep BundleInterface
as the mock parent.
Not sure I'm super clear here 😄
11a767b
to
ceef8cd
Compare
ceef8cd
to
4fc71c7
Compare
getMockForAbstractClass()
getMockForAbstractClass()
@alexandre-daubois Can you rebase please? |
4fc71c7
to
295fabe
Compare
295fabe
to
2b284d7
Compare
src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
Outdated
Show resolved
Hide resolved
...ony/Bundle/SecurityBundle/Tests/DependencyInjection/Security/Factory/AbstractFactoryTest.php
Show resolved
Hide resolved
2b284d7
to
a19b087
Compare
protected function normalizeValue($value) | ||
{ | ||
} | ||
|
||
protected function mergeValues($leftSide, $rightSide) | ||
{ | ||
} | ||
|
||
protected function finalizeValue($value) | ||
{ | ||
} |
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.
Those methods need to return something. Otherwise we won't be able to ad a return type after merging up.
protected function normalizeValue($value) | |
{ | |
} | |
protected function mergeValues($leftSide, $rightSide) | |
{ | |
} | |
protected function finalizeValue($value) | |
{ | |
} | |
protected function normalizeValue($value) | |
{ | |
return null; | |
} | |
protected function mergeValues($leftSide, $rightSide) | |
{ | |
return null; | |
} | |
protected function finalizeValue($value) | |
{ | |
return null; | |
} |
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.
Given that they return mixed
, I think it would still work at up-merge without the return statement? I added return statement anyway, better be safe than sorry 🙂
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 should also add return types to other anonymous classes, I'm on it.
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.
Better now 👍
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.
Given that they return
mixed
, I think it would still work at up-merge without the return statement?
Yes, but whoever does the merge-up will have to think less when doing so. 😅 Also, the diff is smaller.
237c3e9
to
2acf005
Compare
2acf005
to
47a7f66
Compare
getMockForAbstractClass()
getMockForAbstractClass()
getMockForAbstractClass()
getMockForAbstractClass()
This method is deprecated (see sebastianbergmann/phpunit#5241), and must be replaced where used.