public function SocialDrupalContext::assertLoggedInWithPermissionsByName in Open Social 8.7
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
- 8.8 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
- 10.3.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
- 10.0.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
- 10.1.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
- 10.2.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertLoggedInWithPermissionsByName()
@Given I am logged in as :name with the :permissions permission(s)
File
- tests/
behat/ features/ bootstrap/ SocialDrupalContext.php, line 319
Class
- SocialDrupalContext
- Provides pre-built step definitions for interacting with Open Social.
Namespace
Drupal\social\BehatCode
public function assertLoggedInWithPermissionsByName($name, $permissions) {
// Create a temporary role with given permissions.
$permissions = array_map('trim', explode(',', $permissions));
$role = $this
->getDriver()
->roleCreate($permissions);
$manager = $this
->getUserManager();
// Change internal current user.
$manager
->setCurrentUser($manager
->getUser($name));
$user = $manager
->getUser($name);
// Assign the temporary role with given permissions.
$this
->getDriver()
->userAddRole($user, $role);
$this->roles[] = $role;
// Login.
$this
->login($user);
}