You are here

public function NestedArrayTest::testMergeImplicitKeys in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php \Drupal\Tests\Component\Utility\NestedArrayTest::testMergeImplicitKeys()

Tests that arrays with implicit keys are appended, not merged.

@covers ::mergeDeepArray

File

core/tests/Drupal/Tests/Component/Utility/NestedArrayTest.php, line 178
Contains \Drupal\Tests\Component\Utility\NestedArrayTest.

Class

NestedArrayTest
@coversDefaultClass \Drupal\Component\Utility\NestedArray @group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function testMergeImplicitKeys() {
  $a = array(
    'subkey' => array(
      'X',
      'Y',
    ),
  );
  $b = array(
    'subkey' => array(
      'X',
    ),
  );

  // Drupal core behavior.
  $expected = array(
    'subkey' => array(
      'X',
      'Y',
      'X',
    ),
  );
  $actual = NestedArray::mergeDeepArray(array(
    $a,
    $b,
  ));
  $this
    ->assertSame($expected, $actual, 'drupal_array_merge_deep() creates new numeric keys in the implicit sequence.');
}