You are here

public function FeatureContext::openFileAndExpectAccess in Open Social 8

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

This opens the files and check for the expected access.

Parameters

$fid:

$expected_access: 0 = NO access 1 = YES access

1 call to FeatureContext::openFileAndExpectAccess()
FeatureContext::openAndCheckFilesPrivateForUser in tests/behat/features/bootstrap/FeatureContext.php
Opens the files uploaded by a given user.

File

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

Class

FeatureContext
Defines application features from the specific context.

Code

public function openFileAndExpectAccess($fid, $expected_access) {

  /** @var \Drupal\file\Entity\File $file */
  $file = \Drupal::entityTypeManager()
    ->getStorage('file')
    ->load($fid);
  $url = $file
    ->url();
  $page = file_url_transform_relative($url);
  $this
    ->visitPath($page);
  if ($expected_access == 0) {
    $this
      ->assertSession()
      ->pageTextContains('Access denied. You must log in to view this page.');
  }
  else {
    $this
      ->assertSession()
      ->pageTextNotContains('Access denied. You must log in to view this page.');
  }
}