function UtilitiesTest::dataProviderIsRenderArray

Same name and namespace in other branches
  1. 10 core/modules/sdc/tests/src/Unit/UtilitiesTest.php \Drupal\Tests\sdc\Unit\UtilitiesTest::dataProviderIsRenderArray()

File

core/modules/sdc/tests/src/Unit/UtilitiesTest.php, line 30

Class

UtilitiesTest
Unit tests for the Utilities class.

Namespace

Drupal\Tests\sdc\Unit

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.