2019-12-24 01:52:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Psl\Tests\Iter;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2020-08-18 05:52:13 +02:00
|
|
|
use Psl\Iter;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
final class ToIteratorTest extends TestCase
|
2019-12-24 01:52:07 +01:00
|
|
|
{
|
2020-08-17 23:33:18 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider provideToIteratorData
|
|
|
|
*/
|
|
|
|
public function testToIterator(array $array): void
|
|
|
|
{
|
|
|
|
$iterator = Iter\to_iterator($array);
|
|
|
|
|
2020-10-15 10:18:03 +02:00
|
|
|
static::assertCount(Iter\count($array), $iterator);
|
|
|
|
static::assertSame($array, Iter\to_array_with_keys($iterator));
|
2020-08-17 23:33:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|