You are here

public function WeightTest::testProcessWeight in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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');
}