You are here

public function ElementTest::testProcessLegendCallable in Lightning Core 8

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/ElementTest.php \Drupal\Tests\lightning_core\Kernel\ElementTest::testProcessLegendCallable()
  2. 8.2 tests/src/Kernel/ElementTest.php \Drupal\Tests\lightning_core\Kernel\ElementTest::testProcessLegendCallable()
  3. 8.3 tests/src/Kernel/ElementTest.php \Drupal\Tests\lightning_core\Kernel\ElementTest::testProcessLegendCallable()
  4. 8.4 tests/src/Kernel/ElementTest.php \Drupal\Tests\lightning_core\Kernel\ElementTest::testProcessLegendCallable()

@covers ::processLegend

File

tests/src/Kernel/ElementTest.php, line 68

Class

ElementTest
@coversDefaultClass \Drupal\lightning_core\Element

Namespace

Drupal\Tests\lightning_core\Kernel

Code

public function testProcessLegendCallable() {
  $legend = function (array $item) {
    return ucfirst($item['#label']);
  };
  $element = [
    'foo' => [
      '#type' => 'checkbox',
      '#label' => 'foo',
    ],
    'bar' => [
      '#type' => 'checkbox',
      '#label' => 'bar',
    ],
    'baz' => [
      '#type' => 'checkbox',
      '#label' => 'baz',
    ],
    '#legend' => $legend,
  ];
  $element = Element::processLegend($element);
  $this
    ->assertEquals('Foo', $element['foo']['#description']);
  $this
    ->assertEquals('Bar', $element['bar']['#description']);
  $this
    ->assertEquals('Baz', $element['baz']['#description']);
}