<?php
namespace Drupal\Tests\Component\Utility;
use Drupal\Tests\UnitTestCase;
use Drupal\Component\Utility\MapArray;
class MapArrayTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'MapArray test',
'description' => 'Test that the MapArray functions work properly.',
'group' => 'Bootstrap',
);
}
public function testCopyValuesToKey(array $input, array $expected, $callable = NULL) {
$output = MapArray::copyValuesToKeys($input, $callable);
$this
->assertEquals($expected, $output);
}
public function providerCopyValuesToKey() {
$tests[] = array(
array(),
array(),
);
$tests[] = array(
array(
'foobar',
),
array(
'foobar' => 'foobar',
),
);
$tests[] = array(
array(
'foo' => 'bar',
),
array(
'bar' => 'bar',
),
);
$tests[] = array(
array(
1,
2,
3,
4,
5,
),
array(
1 => 2,
2 => 4,
3 => 6,
4 => 8,
5 => 10,
),
'Drupal\\Tests\\Component\\Utility\\MapArrayTest::providerCopyValuesToKeyCallback',
);
return $tests;
}
public static function providerCopyValuesToKeyCallback($n) {
return $n * 2;
}
}