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

46 lines
942 B
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 FlattenTest extends TestCase
{
2019-12-25 00:35:14 +01:00
/**
* @dataProvider provideData
*/
2020-08-25 02:17:33 +02:00
public function testFlatten(array $expected, array $arrays): void
2019-12-25 00:35:14 +01:00
{
2020-08-25 02:17:33 +02:00
self::assertSame($expected, Arr\flatten($arrays));
2019-12-25 00:35:14 +01:00
}
public function provideData(): array
{
return [
[
['a' => 'b', 'b' => 'c', 'c' => 'd', 'd' => 'e'],
2020-08-25 02:17:33 +02:00
[
['a' => 'foo', 'b' => 'bar'],
2019-12-25 00:35:14 +01:00
['a' => 'b'],
2020-08-25 02:17:33 +02:00
['b' => 'c', 'c' => 'd'],
['d' => 'baz'],
['d' => 'e'],
],
2019-12-25 00:35:14 +01:00
],
[
[1, 2, 9, 8],
[
[0 => 1, 1 => 2],
[2 => 9, 3 => 8],
],
],
];
}
2019-12-24 01:52:07 +01:00
}