public function FeatureContext::openFileAndExpectAccess in Open Social 8.4
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openFileAndExpectAccess()
- 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\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 734
Class
- FeatureContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
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.');
}
}