function LanguageSelectElementTest::_testLanguageSelectElementOptions

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php \Drupal\Tests\system\Functional\Form\LanguageSelectElementTest::_testLanguageSelectElementOptions()
  2. 10 core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php \Drupal\Tests\system\Functional\Form\LanguageSelectElementTest::_testLanguageSelectElementOptions()
  3. 11.x core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php \Drupal\Tests\system\Functional\Form\LanguageSelectElementTest::_testLanguageSelectElementOptions()

Helper function to check the options of a language select form element.

Parameters

string $id: The id of the language select element to check.

array $options: An array with options to compare with.

1 call to LanguageSelectElementTest::_testLanguageSelectElementOptions()
LanguageSelectElementTest::testLanguageSelectElementOptions in core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php
Tests that the options printed by the language select element are correct.

File

core/modules/system/tests/src/Functional/Form/LanguageSelectElementTest.php, line 106

Class

LanguageSelectElementTest
Tests the language selection form element.

Namespace

Drupal\Tests\system\Functional\Form

Code

protected function _testLanguageSelectElementOptions($id, $options) {
    // Check that the options in the language field are exactly the same,
    // including the order, as the languages sent as a parameter.
    $found_options = $this->assertSession()
        ->selectExists($id)
        ->findAll('css', 'option');
    $found_options = array_map(function ($item) {
        return $item->getText();
    }, $found_options);
    $this->assertEquals(array_values($options), $found_options);
}

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