You are here

public function DurationFieldBrowserTestBase::assertRadioSelected in Duration Field 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/DurationFieldBrowserTestBase.php \Drupal\Tests\duration_field\Functional\DurationFieldBrowserTestBase::assertRadioSelected()
  2. 8 tests/src/Functional/DurationFieldBrowserTestBase.php \Drupal\Tests\duration_field\Functional\DurationFieldBrowserTestBase::assertRadioSelected()

Asserts that the value of a radio element was selected.

File

tests/src/Functional/DurationFieldBrowserTestBase.php, line 57

Class

DurationFieldBrowserTestBase
Base class that provides some helper functions for functional tests.

Namespace

Drupal\Tests\duration_field\Functional

Code

public function assertRadioSelected($htmlID) {
  if (!preg_match('/^#/', $htmlID)) {
    $htmlID = '#' . $htmlID;
  }
  $selected_radio = $this
    ->getSession()
    ->getPage()
    ->find('css', 'input[type="radio"]:checked' . $htmlID);
  if (!$selected_radio) {
    throw new \Exception('Radio button with ID ' . $htmlID . ' is not selected');
  }
}