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

34 lines
806 B
PHP
Raw Normal View History

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\Collection;
use Psl\Iter;
2019-12-24 01:52:07 +01:00
class ValuesTest extends TestCase
{
2020-08-17 23:33:18 +02:00
/**
* @dataProvider provideTestValues
*/
public function testValues(array $expected, iterable $iterable): void
{
$result = Iter\values($iterable);
$result = Iter\to_array($result);
static::assertSame($expected, $result);
}
public function provideTestValues(): iterable
{
yield [[], []];
yield [[null], [null]];
yield [[1, 2], [1, 2]];
yield [[1, 2, 3, 4, 5], Iter\range(1, 5)];
yield [['hello', 'world'], new Collection\Map(['foo' => 'hello', 'bar' => 'world'])];
yield [['foo', 'bar'], new Collection\Vector(['foo', 'bar'])];
}
2019-12-24 01:52:07 +01:00
}