function NestedArrayTest::testMergeDeepArray
Tests NestedArray::mergeDeepArray().
@covers ::mergeDeep
      
    
@covers ::mergeDeepArray
      
    
File
- 
              core/tests/ Drupal/ Tests/ Component/ Utility/ NestedArrayTest.php, line 152 
Class
- NestedArrayTest
- @coversDefaultClass \Drupal\Component\Utility\NestedArray[[api-linebreak]] @group Utility
Namespace
Drupal\Tests\Component\UtilityCode
public function testMergeDeepArray() : void {
  $link_options_1 = [
    'fragment' => 'x',
    'attributes' => [
      'title' => 'X',
      'class' => [
        'a',
        'b',
      ],
    ],
    'language' => 'en',
  ];
  $link_options_2 = [
    'fragment' => 'y',
    'attributes' => [
      'title' => 'Y',
      'class' => [
        'c',
        'd',
      ],
    ],
    'absolute' => TRUE,
  ];
  $expected = [
    'fragment' => 'y',
    'attributes' => [
      'title' => 'Y',
      'class' => [
        'a',
        'b',
        'c',
        'd',
      ],
    ],
    'language' => 'en',
    'absolute' => TRUE,
  ];
  $this->assertSame($expected, NestedArray::mergeDeepArray([
    $link_options_1,
    $link_options_2,
  ]), 'NestedArray::mergeDeepArray() returned a properly merged array.');
  // Test wrapper function, NestedArray::mergeDeep().
  $this->assertSame($expected, NestedArray::mergeDeep($link_options_1, $link_options_2), 'NestedArray::mergeDeep() returned a properly merged array.');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
