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;
|
2019-12-24 01:52:07 +01:00
|
|
|
|
|
|
|
class SelectKeysTest extends TestCase
|
|
|
|
{
|
2019-12-25 00:35:14 +01:00
|
|
|
/**
|
|
|
|
* @dataProvider provideData
|
|
|
|
*/
|
|
|
|
public function testSelectKeys(array $result, array $array, iterable $keys): void
|
|
|
|
{
|
|
|
|
self::assertSame($result, Arr\select_keys($array, $keys));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideData(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
['foo' => 'bar', 'bar' => 'baz'],
|
|
|
|
['foo' => 'bar', 'bar' => 'baz', 'baz' => 'qux', 'qux' => 'foo'],
|
|
|
|
['foo', 'bar'],
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
[],
|
|
|
|
['baz' => 'qux', 'qux' => 'foo'],
|
|
|
|
['foo', 'bar'],
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
['foo', 'bar'],
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
[],
|
|
|
|
['foo' => 'bar', 'bar' => 'baz', 'baz' => 'qux', 'qux' => 'foo'],
|
|
|
|
[],
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
[],
|
|
|
|
['foo' => 'bar', 'bar' => 'baz', 'baz' => 'qux', 'qux' => 'foo'],
|
|
|
|
['a', 'b'],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2019-12-24 01:52:07 +01:00
|
|
|
}
|