public function LinkOwnershipAccessTest::doFlagOwnershipAccessTest in Flag 8.4
1 call to LinkOwnershipAccessTest::doFlagOwnershipAccessTest()
- LinkOwnershipAccessTest::testFlagOwnershipAccess in tests/
src/ Functional/ LinkOwnershipAccessTest.php - Test ownership access.
File
- tests/
src/ Functional/ LinkOwnershipAccessTest.php, line 39
Class
- LinkOwnershipAccessTest
- Tests the current user sees links for their own flaggings, or global ones.
Namespace
Drupal\Tests\flag\FunctionalCode
public function doFlagOwnershipAccessTest() {
// Create a non-global flag.
$flag = $this
->createFlag();
// Grant the flag permissions to the authenticated role, so that both
// users have the same roles and share the render cache.
$this
->grantFlagPermissions($flag);
// Create and login a new user.
$user_1 = $this
->drupalCreateUser();
$this
->drupalLogin($user_1);
// Flag the node with user 1.
$this
->drupalGet($this->node
->toUrl());
$this
->clickLink($flag
->getShortText('flag'));
$this
->assertResponse(200);
$this
->assertLink($flag
->getShortText('unflag'));
// Switch to user 2. They should see the link to flag.
$user_2 = $this
->drupalCreateUser();
$this
->drupalLogin($user_2);
$this
->drupalGet($this->node
->toUrl());
$this
->assertLink($flag
->getShortText('flag'), 0, "A flag link is found on the page for user 2.");
}