-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Ingore PHPUnit and Prophecy object when they are nested #15175
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
[VarDumper] Ingore PHPUnit and Prophecy object when they are nested #15175
Conversation
@@ -69,6 +69,10 @@ | |||
'Symfony\Component\DependencyInjection\ContainerInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals', | |||
'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castThrowingCasterException', | |||
|
|||
'PHPUnit_Framework_MockObject_MockObject' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals', | |||
'PHPUnit_Framework_MockObject_Stub' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals', | |||
'Prophecy\Prophecy\ProphecyInterface' => 'Symfony\Component\VarDumper\Caster\StubCaster::cutInternals', |
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 think this should be applied on ProphecySubjectInterface
, not on ProphecyInterface
. Prophecy\Prophecy\ProphecyInterface
is the object used to configure the mock. If you are dumping this one, you probably want to see the internals. The test double will implement Prophecy\Prophecy\ProphecySubjectInterface
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 does not work, did I miss something?
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, it depends where you are trying to dump things actually. Can you show a snippet of your code to see where you used dumping together with Prophecy ?
but in any case, Prophecy\Prophecy\ProphecyInterface
is only implemented on pure Prophecy objects (i.e. not extending your code at all). I'm not sure it makes sense to cut all internals there.
Maybe we would only need to cut only the circular reference between the ObjectProphecy (implementing this interface) and the MethodProphecy when dumping.
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 put a snippet in the PR description.
should we also cut internals for Mockery mocks ? |
I don't use Mockery... So no ? ;) |
@lyrixx |
64fe225
to
b24992d
Compare
I added support for Mockery |
@lyrixx In the case of Prophecy, |
b24992d
to
df8bd14
Compare
@stof Ah, Got it ;)Thanks. Fixed. |
df8bd14
to
2bea373
Compare
👍 |
👍 |
Thank you @lyrixx. |
…ey are nested (lyrixx) This PR was merged into the 2.8 branch. Discussion ---------- [VarDumper] Ingore PHPUnit and Prophecy object when they are nested | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - The purpose of this PR is to ignore nested PHPUnit/Prophecy object when `dump`ing. Reproducer: ```php $a = $this->getMock('Datetime'); $b = $this->prophesize('Datetime')->reveal(); $std = new \stdClass; $std->my = 'property'; $std->a = $a; $std->b = $b; die(dump($a, $b, $std)); ``` => ``` {#86 +"my": "property" +"a": Mock_Datetime_8ba7f351 {#22 …5} +"b": Double\DateTime\P1 {#90 …1} } ``` Commits ------- 2bea373 [VarDumper] Ingore PHPUnit and Prophecy object when they are nested
The purpose of this PR is to ignore nested PHPUnit/Prophecy object when
dump
ing.Reproducer:
=>