You are here

public function FeatureContext::openEntityAndExpectAccess in Open Social 8

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

This opens the entity and check for the expected access.

Parameters

$entity_type:

$entity_id:

$expected_access: 0 = NO access 1 = YES access

1 call to FeatureContext::openEntityAndExpectAccess()
FeatureContext::openAndCheckGroupContentAccess in tests/behat/features/bootstrap/FeatureContext.php
Opens the content from a group and check for access.

File

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

Class

FeatureContext
Defines application features from the specific context.

Code

public function openEntityAndExpectAccess($entity_type, $entity_id, $expected_access) {
  $entity = entity_load($entity_type, $entity_id);

  /** @var \Drupal\Core\Url $url */
  $url = $entity
    ->toUrl();
  $page = $url
    ->toString();
  $this
    ->visitPath($page);
  if ($expected_access == 0) {
    $this
      ->assertSession()
      ->pageTextContains('Access denied');
  }
  else {
    $this
      ->assertSession()
      ->pageTextNotContains('Access denied');
  }
}