Remove support for generators in assertCount() and Count constraint #4567
Labels
feature/assertion
Issues related to assertions and expectations
type/deprecation
Something will be/is deprecated
Milestone
#2690, #3302, #3347, and #4229 are examples of problems related to the fact that
assertCount()
(and the underlyingCount
constraint) claim to support countingGenerator
objects when in fact they cannot.Instead of trying to work around the issue by storing the result of
$this->getCountOf($other);
for subsequent invocations, I believe the right course of action is to remove support for generators inassertCount()
andCount
constraint.Generators can only be iterated over once and cannot be cloned. Passing a
Generator
object toassertCount()
therefore changes the state of something that is supposed to be only verified.The text was updated successfully, but these errors were encountered: