Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Render / Element / WeightTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Render\Element;
4
5 use Drupal\Core\Form\FormState;
6 use Drupal\Core\Render\Element\Weight;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Render\Element\Weight
11  * @group Render
12  */
13 class WeightTest extends KernelTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected static $modules = ['system'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->installConfig(['system']);
26   }
27
28   /**
29    * Test existing #default_value value in #options list.
30    *
31    * @covers ::processWeight
32    */
33   public function testProcessWeight() {
34     $element = [];
35     $form_state = new FormState();
36     $complete_form = [];
37
38     $element_object = new Weight([], 'weight', []);
39     $info = $element_object->getInfo();
40     $element += $info;
41
42     $element['#default_value'] = $element['#delta'] + 5;
43
44     Weight::processWeight($element, $form_state, $complete_form);
45
46     $this->assertTrue(
47       isset($element['#options'][$element['#default_value']]),
48       'Default value exists in the #options list'
49     );
50   }
51
52 }