public function MapArrayTest::providerCopyValuesToKey

Data provider for MapArray::copyValuesToKey().

Return value

array An array of tests, matching the parameter inputs for testCopyValuesToKey.

See also

Drupal\Component\Utility\MapArray::copyValuesToKey()

Drupal\Tests\Component\Utility\MapArrayTest::testCopyValuesToKey()

File

drupal/core/tests/Drupal/Tests/Component/Utility/MapArrayTest.php, line 57
Contains \Drupal\Tests\Component\Utility\MapArrayTest.

Class

MapArrayTest
Tests the MapArray system.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerCopyValuesToKey() {

  // Test an empty array.
  $tests[] = array(
    array(),
    array(),
  );

  // Tests the creation of an associative array.
  $tests[] = array(
    array(
      'foobar',
    ),
    array(
      'foobar' => 'foobar',
    ),
  );

  // Tests overwriting indexes with their value.
  $tests[] = array(
    array(
      'foo' => 'bar',
    ),
    array(
      'bar' => 'bar',
    ),
  );

  // Tests using the callback function.
  $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;
}