4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Tests\Argument;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
17 class RewindableGeneratorTest extends TestCase
19 public function testImplementsCountable()
21 $this->assertInstanceOf(\Countable::class, new RewindableGenerator(function () {
26 public function testCountUsesProvidedValue()
28 $generator = new RewindableGenerator(function () {
32 $this->assertCount(3, $generator);
35 public function testCountUsesProvidedValueAsCallback()
38 $generator = new RewindableGenerator(function () {
40 }, function () use (&$called) {
46 $this->assertSame(0, $called, 'Count callback is called lazily');
47 $this->assertCount(3, $generator);
51 $this->assertSame(1, $called, 'Count callback is called only once');