You are here

public function FormElementHelperTest::getElementByNameProvider in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Form/FormElementHelperTest.php \Drupal\Tests\Core\Form\FormElementHelperTest::getElementByNameProvider()
  2. 9 core/tests/Drupal/Tests/Core/Form/FormElementHelperTest.php \Drupal\Tests\Core\Form\FormElementHelperTest::getElementByNameProvider()

Provides test data.

File

core/tests/Drupal/Tests/Core/Form/FormElementHelperTest.php, line 32

Class

FormElementHelperTest
Tests the form element helper.

Namespace

Drupal\Tests\Core\Form

Code

public function getElementByNameProvider() {
  $data = [];
  $data[] = [
    'id',
    [],
    [],
  ];
  $data[] = [
    'id',
    [
      'id' => [
        '#title' => 'ID',
        '#parents' => [
          'id',
        ],
      ],
    ],
    [
      '#title' => 'ID',
      '#parents' => [
        'id',
      ],
    ],
  ];
  $data[] = [
    'id',
    [
      'fieldset' => [
        'id' => [
          '#title' => 'ID',
          '#parents' => [
            'id',
          ],
        ],
        '#parents' => [
          'fieldset',
        ],
      ],
    ],
    [
      '#title' => 'ID',
      '#parents' => [
        'id',
      ],
    ],
  ];
  $data[] = [
    'fieldset',
    [
      'fieldset' => [
        'id' => [
          '#title' => 'ID',
          '#parents' => [
            'id',
          ],
        ],
        '#parents' => [
          'fieldset',
        ],
      ],
    ],
    [
      'id' => [
        '#title' => 'ID',
        '#parents' => [
          'id',
        ],
      ],
      '#parents' => [
        'fieldset',
      ],
    ],
  ];
  $data[] = [
    'fieldset][id',
    [
      'fieldset' => [
        '#tree' => TRUE,
        'id' => [
          '#title' => 'ID',
          '#parents' => [
            'fieldset',
            'id',
          ],
        ],
        '#parents' => [
          'fieldset',
        ],
      ],
    ],
    [
      '#title' => 'ID',
      '#parents' => [
        'fieldset',
        'id',
      ],
    ],
  ];
  return $data;
}