function ArrayHelperTest::testFilterKeys in Helper 7
File
- tests/
ArrayHelperTest.test, line 67
Class
Code
function testFilterKeys() {
$input = array_fill_keys(range(0, 10), 'test');
$expected1 = array_fill_keys(array(
0,
3,
6,
9,
), 'test');
$expected2 = array_fill_keys(array(
1,
2,
4,
5,
7,
8,
10,
), 'test');
$result = ArrayHelper::filterKeys($input, function ($value) {
return $value % 3 === 0;
}, $input);
$this
->assertIdentical($result, $expected1);
$result = ArrayHelper::filterKeys($input, function ($value) {
return $value % 3;
}, $input);
$this
->assertIdentical($result, $expected2);
}