You are here

public function NestedArrayTest::testMergeDeepArray 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::testMergeDeepArray()

Tests NestedArray::mergeDeepArray().

@covers ::mergeDeep @covers ::mergeDeepArray

File

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

Class

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

Namespace

Drupal\Tests\Component\Utility

Code

public function testMergeDeepArray() {
  $link_options_1 = array(
    'fragment' => 'x',
    'attributes' => array(
      'title' => 'X',
      'class' => array(
        'a',
        'b',
      ),
    ),
    'language' => 'en',
  );
  $link_options_2 = array(
    'fragment' => 'y',
    'attributes' => array(
      'title' => 'Y',
      'class' => array(
        'c',
        'd',
      ),
    ),
    'absolute' => TRUE,
  );
  $expected = array(
    'fragment' => 'y',
    'attributes' => array(
      'title' => 'Y',
      'class' => array(
        'a',
        'b',
        'c',
        'd',
      ),
    ),
    'language' => 'en',
    'absolute' => TRUE,
  );
  $this
    ->assertSame($expected, NestedArray::mergeDeepArray(array(
    $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.');
}