diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index 3731f06..7df29f3 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -469,7 +469,6 @@ public function testEmptySelect() { */ public function testSelectSorting() { $this->drupalGet('form-test/select'); - $content = $this->getSession()->getPage()->getContent(); // Verify the order of the select options. $this->validateSelectSorting('unsorted', [ @@ -549,17 +548,17 @@ public function testSelectSorting() { * @param string[] $order * Expected order of its options. */ - protected function validateSelectSorting($select, $order) { - $option_map_function = function (NodeElement $option) { - if ($option->getTagName() === 'optgroup') { - return $option->getAttribute('label'); - } - return $option->getValue(); + protected function validateSelectSorting($select, array $order) { + $option_map_function = function (NodeElement $node) { + return ($node->getTagName() === 'optgroup') ? + $node->getAttribute('label') : $node->getValue(); }; + $option_nodes = $this->getSession() + ->getPage() + ->findField($select) + ->findAll('css', 'option, optgroup'); - $field = $this->getSession()->getPage()->findField($select); - $options = array_map($option_map_function, - $field->findAll('css', 'option, optgroup')); + $options = array_map($option_map_function, $option_nodes); $this->assertIdentical($order, $options); }