endtoend-test-psl/tests/Psl/Arr/ConcatTest.php

51 lines
1.2 KiB
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Arr;
use PHPUnit\Framework\TestCase;
2019-12-25 00:35:14 +01:00
use Psl\Arr;
use Psl\Collection;
2019-12-24 01:52:07 +01:00
class ConcatTest extends TestCase
{
2019-12-25 00:35:14 +01:00
/**
* @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']),
2020-02-21 02:03:40 +01:00
new Collection\MutableVector(['baz', 'qux']),
2019-12-25 00:35:14 +01:00
],
[
[1, 2, 3],
[1, 2, 3],
],
[
['a', 'b', 'c', 'd', 'e'],
['a'],
(fn () => yield 'b')(),
new Collection\Map(['c']),
2020-02-21 02:03:40 +01:00
new Collection\MutableVector(['d']),
new Collection\Vector(['e']),
2019-12-25 00:35:14 +01:00
],
];
}
2019-12-24 01:52:07 +01:00
}