mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-02 17:56:09 +01:00
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Arr;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl\Arr;
|
|
use Psl\Collection;
|
|
|
|
/**
|
|
* @covers \Psl\Arr\concat
|
|
*/
|
|
class ConcatTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testConcat(array $expected, iterable $first, iterable ...$other): void
|
|
{
|
|
static::assertSame($expected, Arr\concat($first, ...$other));
|
|
}
|
|
|
|
public function provideData(): array
|
|
{
|
|
return [
|
|
[
|
|
['a', 'b', 'c'],
|
|
['foo' => 'a'],
|
|
['bar' => 'b'],
|
|
['baz' => 'c'],
|
|
],
|
|
[
|
|
['foo', 'bar', 'baz', 'qux'],
|
|
new Collection\Map(['foo']),
|
|
new Collection\Vector(['bar']),
|
|
new Collection\Pair('baz', 'qux'),
|
|
],
|
|
[
|
|
[1, 2, 3],
|
|
[1, 2, 3],
|
|
],
|
|
[
|
|
['a', 'b', 'c', 'd', 'e'],
|
|
['a'],
|
|
(fn () => yield 'b')(),
|
|
new Collection\Map(['c']),
|
|
new Collection\Vector(['d']),
|
|
new Collection\ImmVector(['e']),
|
|
],
|
|
];
|
|
}
|
|
}
|