function ElementTest::testInvalidChildren

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

Tests the children() method with an invalid key.

File

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

Class

ElementTest
@coversDefaultClass \Drupal\Core\Render\Element @group Render

Namespace

Drupal\Tests\Core\Render

Code

public function testInvalidChildren() : void {
    $element = [
        'foo' => 'bar',
    ];
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('"foo" is an invalid render array key. Value should be an array but got a string.');
    Element::children($element);
}

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