endtoend-test-psl/tests/Psl/Arr/SelectKeysTest.php
2020-08-27 15:14:37 +01:00

55 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Arr;
use PHPUnit\Framework\TestCase;
use Psl\Arr;
class SelectKeysTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testSelectKeys(array $result, array $array, array $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'],
],
];
}
}