function ElementTest::dataProviderIsRenderArray

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Render/ElementTest.php \Drupal\Tests\Core\Render\ElementTest::dataProviderIsRenderArray()

File

core/tests/Drupal/Tests/Core/Render/ElementTest.php, line 239

Class

ElementTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element.php/class/Element/11.x" title="Provides helper methods for Drupal render elements." class="local">\Drupal\Core\Render\Element</a> @group Render

Namespace

Drupal\Tests\Core\Render

Code

public static function dataProviderIsRenderArray() {
    return [
        'valid markup render array' => [
            [
                '#markup' => 'hello world',
            ],
            TRUE,
        ],
        'invalid "foo" string' => [
            [
                'foo',
                '#markup' => 'hello world',
            ],
            FALSE,
        ],
        'null is not an array' => [
            NULL,
            FALSE,
        ],
        'an empty array is not a render array' => [
            [],
            FALSE,
        ],
        'funny enough a key with # is valid' => [
            [
                '#' => TRUE,
            ],
            TRUE,
        ],
        'nested arrays can be valid too' => [
            [
                'one' => [
                    2 => [
                        '#three' => 'charm!',
                    ],
                ],
            ],
            TRUE,
        ],
    ];
}

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