You are here

public function FeatureContext::iSelectPostVisibility in Open Social 8

Same name and namespace in other branches
  1. 8.2 tests/behat/features/bootstrap/FeatureContext.php \FeatureContext::iSelectPostVisibility()

@When I select post visibility :visibility

File

tests/behat/features/bootstrap/FeatureContext.php, line 198

Class

FeatureContext
Defines application features from the specific context.

Code

public function iSelectPostVisibility($visibility) {
  $allowed_visibility = array(
    '0' => 'Recipient',
    // Is displayed as Community in front-end.
    '1' => 'Public',
    '2' => 'Community',
    '3' => 'Group members',
  );
  if (!in_array($visibility, $allowed_visibility)) {
    throw new \InvalidArgumentException(sprintf('This visibility option is not allowed: "%s"', $visibility));
  }

  // First make post visibility setting visible.
  $this
    ->iClickPostVisibilityDropdown();

  // Click the radio button.
  $key = array_search($visibility, $allowed_visibility);
  if (!empty($key)) {
    $id = 'edit-field-visibility-0-' . $key;
    $this
      ->clickRadioButton('', $id);
  }
  else {
    throw new \InvalidArgumentException(sprintf('Could not find key for visibility option: "%s"', $visibility));
  }

  // Hide post visibility setting.
  $this
    ->iClickPostVisibilityDropdown();
}