function BubbleableMetadataTest::providerTestMergeAttachmentsHtmlHeadMerging

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::providerTestMergeAttachmentsHtmlHeadMerging()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::providerTestMergeAttachmentsHtmlHeadMerging()
  3. 11.x core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::providerTestMergeAttachmentsHtmlHeadMerging()

Data provider for testMergeAttachmentsHtmlHeadMerging.

Return value

array

File

core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php, line 401

Class

BubbleableMetadataTest
@coversDefaultClass \Drupal\Core\Render\BubbleableMetadata @group Render

Namespace

Drupal\Tests\Core\Render

Code

public static function providerTestMergeAttachmentsHtmlHeadMerging() {
    $meta = [
        '#tag' => 'meta',
        '#attributes' => [
            'charset' => 'utf-8',
        ],
        '#weight' => -1000,
    ];
    $html_tag = [
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => [
            'name' => 'Generator',
            'content' => 'Kitten 1.0 (https://www.drupal.org/project/kitten)',
        ],
    ];
    $a = [
        'html_head' => [
            $meta,
            'system_meta_content_type',
        ],
    ];
    $b = [
        'html_head' => [
            $html_tag,
            'system_meta_generator',
        ],
    ];
    $expected_a = [
        'html_head' => [
            $meta,
            'system_meta_content_type',
            $html_tag,
            'system_meta_generator',
        ],
    ];
    // Merging in the opposite direction yields the opposite library order.
    $expected_b = [
        'html_head' => [
            $html_tag,
            'system_meta_generator',
            $meta,
            'system_meta_content_type',
        ],
    ];
    return [
        [
            $a,
            $b,
            $expected_a,
        ],
        [
            $b,
            $a,
            $expected_b,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.