You are here

public function ForcePasswordChangeBrowserTestBase::assertSelectOption in Force Password Change 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/ForcePasswordChangeBrowserTestBase.php \Drupal\Tests\force_password_change\Functional\ForcePasswordChangeBrowserTestBase::assertSelectOption()
1 call to ForcePasswordChangeBrowserTestBase::assertSelectOption()
ForcePasswordChangeAdminUiTest::testForcePasswordChangeAdminPage in tests/src/Functional/ForcePasswordChangeAdminUiTest.php
* Test that the admin UI page is properly linked to, that all the required elements * exist, and that the form is working properly

File

tests/src/Functional/ForcePasswordChangeBrowserTestBase.php, line 110

Class

ForcePasswordChangeBrowserTestBase
Provides some helper functions for functional tests.

Namespace

Drupal\Tests\force_password_change\Functional

Code

public function assertSelectOption($selectElementHtmlID, $value) {
  if (preg_match('/^#/', $selectElementHtmlID)) {
    $selectElementHtmlID = substr($selectElementHtmlID, 1);
  }
  $selected_option = $this
    ->getSession()
    ->getPage()
    ->find('xpath', '//select[@id="' . $selectElementHtmlID . '"]/option[@value="' . $value . '" and @selected="selected"]');
  if (!$selected_option) {
    throw new \Exception('Select ' . $selectElementHtmlID . ' does not have value "' . $value . '" selected');
  }
}