Skip to content
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

Prophecy not supported returning by reference ORM 2.6 #413

Open
mayro opened this issue Aug 14, 2018 · 3 comments
Open

Prophecy not supported returning by reference ORM 2.6 #413

mayro opened this issue Aug 14, 2018 · 3 comments

Comments

@mayro
Copy link

mayro commented Aug 14, 2018

Hello,
I use Prophecy to testing my code. I have this code in my test class

$unitOfWork = $this->prophesize(UnitOfWork::class);
$unitOfWork->getEntityChangeSet(Argument::exact($account))->willReturn($changeSet)->shouldBeCalled();

With Doctrine/Orm V2.6, so my test doesn't pass anymore, with return by reference in getEntityChangeSet Prophecy\Exception\Doubler\ReturnByReferenceException: Returning by reference not supported

Have you any suggestion to testing my class with Prophecy?

Thanks.

@DonCallisto
Copy link
Contributor

That's not possible with Prophecy.
I really don't know the reasons of this behaviour but I suppose is due to "double" encapsulation and those kind of things.

If you would like to test a class that relies on third party code you should not use Prophecy (more in general you should not do unit tests) at all: do other kind of test (functional, e2e, integration, etc)

@sstok
Copy link
Contributor

sstok commented Mar 9, 2019

I suggest you read this http://docs.park-manager.com/en/latest/contributing/code/testing.html#don-t-mock-a-type-you-don-t-own 👍

@Seldaek
Copy link
Contributor

Seldaek commented Aug 29, 2019

Duplicate of #225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants