protected function 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 drupal/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
Tests that the options printed by the language select element are correct.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php, line 107
Definition of Drupal\system\Tests\Form\LanguageSelectElementTest.

Class

LanguageSelectElementTest
Functional tests for the language select form element.

Namespace

Drupal\system\Tests\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.
  $elements = $this
    ->xpath("//select[@id='" . $id . "']");
  $count = 0;
  foreach ($elements[0]->option as $option) {
    $count++;
    $option_title = current($options);
    $this
      ->assertEqual((string) $option, $option_title);
    next($options);
  }
  $this
    ->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array(
    '@languages' => count($options),
    '@number' => $count,
  )));
}