Problem/Motivation
Something in phpspec/prophecy 1.10.0 makes our tests fail on php7.3
They were passing previously
See https://github.com/phpspec/prophecy/compare/1.9.0...1.10.0
And https://github.com/phpspec/prophecy/pull/446
https://github.com/phpspec/prophecy/pull/446 changed the way that comparison for the default token (ExactValueToken) is done for closures.
With prophecy, when you do this:
$this->prophesize(Some:class)->someMethod($some_argument);
Internally it turns $some_argument into new \Prophecy\Argument\Token\ExactValueToken($some_argument) and then calls \Prophecy\Argument\Token\ExactValueToken::scoreArgument which now returns false if the comparator throws a ComparisonFailure
For closures, the comparator used is \Prophecy\Comparator\ClosureComparator which always throws a ComparisonFailure
Proposed resolution
The fix, is to use the long-form and instead of using the default ExactValueToken, use Argument::is() which maps to \Prophecy\Argument\Token\IdenticalValueToken which just does a straight equality comparison, which is fine for the two closures in the test that are broken.
The code we're calling in core that is failing
$this->decoratedFormState->prepareCallback($unprepared_callback)
->willReturn($prepared_callback)
->shouldBeCalled();
$this->assertSame($prepared_callback, $this->formStateDecoratorBase->prepareCallback($unprepared_callback));
Where in this scenario, $unprepared_callback and $prepared_callback is a closure, causing the fail.
We actually expect direct equality here, so we should use Argument::is
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3101720.patch | 999 bytes | larowlan |
Comments
Comment #2
larowlanhttps://github.com/phpspec/prophecy/pull/446 is the issue that broke it (found with git bisect on prophecy)
Comment #3
larowlanOpened https://github.com/phpspec/prophecy/pull/456 but I think we can resolve this in a different way.
Comment #4
larowlanComment #5
kim.pepper+1 RTBC if green
Comment #6
eric115 commentedLooks good, marking as RTBC
Comment #7
larowlanThis is broken on php 7.2 as well, all the way back to 8.7.x
Comment #8
mstrelan commentedFor searchability ... this issue fixed the below error in phpunit:
Comment #9
alexpottCommitted and pushed 525a4b9bbb to 9.0.x and 73a1544e26 to 8.9.x. Thanks!
Leaving at rtbc for 8.8.x and 8.7.x backport.
Comment #13
larowlanc/p to 8.8.x and 8.7.x
Comment #16
xjmWhy was this backported to 8.7? Under normal circumstances, a commit made to the security branch by normal process will never be released because releases are just created on the top of the last tag. This means no security release would ever have benefited from this fix, and indeed 8.8.1 didn't and the one this week won't.
If you have a reason that there is something that needs to be included in a security release, contact a release manager to ensure a normal patch release gets made against the branch.