function ElementTest::dataProviderIsRenderArray

Same name in other branches
  1. 11.x 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 \Drupal\Core\Render\Element @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.