mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-12 09:09:45 +01:00
34 lines
798 B
PHP
34 lines
798 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Iter;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Iter;
|
|
|
|
class EnumerateTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testEnumerate(array $expected, iterable $iterable): void
|
|
{
|
|
$result = Iter\enumerate($iterable);
|
|
|
|
self::assertSame($expected, Iter\to_array_with_keys($result));
|
|
}
|
|
|
|
public function provideData(): iterable
|
|
{
|
|
yield [[], []];
|
|
yield [[['a', 'b'], ['c', 'd']], ['a' => 'b', 'c' => 'd']];
|
|
yield [[['a', 'b'], ['a', 'b'], ['a', 'b']], (static function () {
|
|
yield 'a' => 'b';
|
|
yield 'a' => 'b';
|
|
yield 'a' => 'b';
|
|
})()];
|
|
yield [[['a', null], ['b', 0]], ['a' => null, 'b' => 0]];
|
|
}
|
|
}
|