phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 241 forks source link

Fix nesting error when comparing objects #446

Closed scroach closed 4 years ago

scroach commented 5 years ago

When mocking method calls with complex objects (doctrine entities) I got PHP errors today: "PHP Fatal error: Nesting level too deep - recursive dependency?"

This issue has already been discussed here: https://github.com/phpspec/prophecy/issues/268

The problem lies in the class method ExactValueToken#scoreArgument When the ObjectComparator throws a ComparisonFailure this method just ignores it - I don't see why because the phpunit comparator works quite well and seems to already cover recursion.

ExactValueToken then goes on and tries to compare the 2 objects with $argument == $this->value which causes a PHP internal nesting error - see also: https://stackoverflow.com/a/19097159/2424814

I've fixed this and added some tests.

drupol commented 4 years ago

This looks good to me.

ciaranmcnulty commented 4 years ago

This looks good; it's not clear from the original commits why the Exception was ignored