You are here

public function FeatureContext::iSelectPostVisibility in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  2. 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  3. 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  4. 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  5. 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  6. 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  7. 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  8. 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  9. 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()
  10. 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iSelectPostVisibility()

@When I select post visibility :visibility

File

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

Class

FeatureContext
Defines application features from the specific context.

Namespace

Drupal\social\Behat

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();
}