-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
PHPUnit and Generators #2149
Comments
Copied here from #1174: <?php
class GeneratorTest extends PHPUnit_Framework_TestCase
{
public static function generator($range)
{
foreach (range(0, $range) as $x) {
yield $x;
}
}
public function testCountingAGeneratorFailsWithPHPWarning()
{
$this->assertCount(10, self::generator(10));
}
}
|
I encounter this again. |
Cause is here: Sooo, possible solutions are to either add in a case for generators so the rewind call is skipped (as previously suggested), or add new assertions which specifically target generators. Thoughts? |
Closed via 4123b6a. |
This allows generators (sebastianbergmann#2149) and internal Traversables (sebastianbergmann#2642) to be properly detected before attempting to restore the Iterator's position after counting (sebastianbergmann#1125).
#1174 is still an issue. The offending code seems to be in 4.xx, 5.xx, and master.
The example test in that thread still applies.
The text was updated successfully, but these errors were encountered: