endtoend-test-psl/tests/Psl/Iter/ToIteratorTest.php

32 lines
674 B
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Iter;
2020-08-17 23:33:18 +02:00
use Psl\Iter;
2019-12-24 01:52:07 +01:00
use PHPUnit\Framework\TestCase;
class ToIteratorTest extends TestCase
{
2020-08-17 23:33:18 +02:00
/**
* @dataProvider provideToIteratorData
*/
public function testToIterator(array $array): void
{
$iterator = Iter\to_iterator($array);
self::assertCount(Iter\count($array), $iterator);
self::assertSame($array, Iter\to_array_with_keys($iterator));
}
public function provideToIteratorData(): iterable
{
yield [[1, 2, 3]];
yield [[null]];
yield [['foo' => 'bar', 'baz' => 'qux']];
yield [[]];
yield [['hello', 'world']];
}
2019-12-24 01:52:07 +01:00
}