function WeightTest::testProcessWeight

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Render/Element/WeightTest.php \Drupal\KernelTests\Core\Render\Element\WeightTest::testProcessWeight()
  2. 10 core/tests/Drupal/KernelTests/Core/Render/Element/WeightTest.php \Drupal\KernelTests\Core\Render\Element\WeightTest::testProcessWeight()
  3. 11.x core/tests/Drupal/KernelTests/Core/Render/Element/WeightTest.php \Drupal\KernelTests\Core\Render\Element\WeightTest::testProcessWeight()

Tests existing #default_value value in #options list.

@covers ::processWeight

File

core/tests/Drupal/KernelTests/Core/Render/Element/WeightTest.php, line 35

Class

WeightTest
@coversDefaultClass \Drupal\Core\Render\Element\Weight @group Render

Namespace

Drupal\KernelTests\Core\Render\Element

Code

public function testProcessWeight() {
    $element = [];
    $form_state = new FormState();
    $complete_form = [];
    $element_object = new Weight([], 'weight', []);
    $info = $element_object->getInfo();
    $element += $info;
    $element['#default_value'] = $element['#delta'] + 5;
    Weight::processWeight($element, $form_state, $complete_form);
    $this->assertTrue(isset($element['#options'][$element['#default_value']]), 'Default value exists in the #options list');
}

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