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

Remove support for generators in assertCount() and Count constraint #4567

Closed
sebastianbergmann opened this issue Dec 28, 2020 · 0 comments
Closed
Assignees
Labels
feature/assertion Issues related to assertions and expectations type/deprecation Something will be/is deprecated
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Dec 28, 2020

#2690, #3302, #3347, and #4229 are examples of problems related to the fact that assertCount() (and the underlying Count constraint) claim to support counting Generator 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 in assertCount() and Count constraint.

Generators can only be iterated over once and cannot be cloned. Passing a Generator object to assertCount() therefore changes the state of something that is supposed to be only verified.

@sebastianbergmann sebastianbergmann added feature/assertion Issues related to assertions and expectations type/deprecation Something will be/is deprecated labels Dec 28, 2020
@sebastianbergmann sebastianbergmann added this to the PHPUnit 10.0 milestone Dec 28, 2020
@sebastianbergmann sebastianbergmann self-assigned this Dec 28, 2020
@sebastianbergmann sebastianbergmann changed the title Deprecate support for generators in assertCount() and Count constraint Remove support for generators in assertCount() and Count constraint Aug 11, 2022
gquemener pushed a commit to gquemener/repositoring that referenced this issue Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/assertion Issues related to assertions and expectations type/deprecation Something will be/is deprecated
Projects
None yet
Development

No branches or pull requests

1 participant