Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

lyrixx
Copy link
Member

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

The purpose of this PR is to ignore nested PHPUnit/Prophecy object whendumping.

Reproducer:

$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}}

@@ -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',
Copy link
Member

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 onProphecySubjectInterface, not onProphecyInterface.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 implementProphecy\Prophecy\ProphecySubjectInterface

Copy link
MemberAuthor

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?

Copy link
Member

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.

Copy link
MemberAuthor

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.

@stof
Copy link
Member

stof commentedJul 2, 2015

should we also cut internals for Mockery mocks ?

@lyrixx
Copy link
MemberAuthor

should we also cut internals for Mockery mocks ?

I don't use Mockery... So no ? ;)

@stof
Copy link
Member

stof commentedJul 2, 2015

@lyrixxMockery\MockInterface is the mockery mock interface.

@lyrixxlyrixxforce-pushed thevar-dump-ignore-testing-tools branch 2 times, most recently from64fe225 tob24992dCompareJuly 2, 2015 13:34
@lyrixx
Copy link
MemberAuthor

I added support for Mockery

@stof
Copy link
Member

stof commentedJul 2, 2015

@lyrixx In the case of Prophecy,$this->prophesize('Datetime') does not give you a test double. It is theProphecy\Prophecy\ObjectProphecy instance used to configure your test double. You will only get the test double after calling->reveal() on it. this is why I said that the interface for which cutting internals makes sense isProphecy\Prophecy\ProphecySubjectInterface

@lyrixxlyrixxforce-pushed thevar-dump-ignore-testing-tools branch fromb24992d todf8bd14CompareJuly 2, 2015 14:20
@lyrixx
Copy link
MemberAuthor

@stof Ah, Got it ;)Thanks. Fixed.

@lyrixxlyrixxforce-pushed thevar-dump-ignore-testing-tools branch fromdf8bd14 to2bea373CompareJuly 2, 2015 14:25
@nicolas-grekas
Copy link
Member

👍

@stof
Copy link
Member

stof commentedJul 2, 2015

👍

@nicolas-grekas
Copy link
Member

Thank you@lyrixx.

@nicolas-grekasnicolas-grekas merged commit2bea373 intosymfony:2.8Jul 2, 2015
nicolas-grekas added a commit that referenced this pull requestJul 2, 2015
…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
@lyrixxlyrixx deleted the var-dump-ignore-testing-tools branchJuly 2, 2015 17:30
@fabpotfabpot mentioned this pull requestNov 16, 2015
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@lyrixx@stof@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp