public function LinkTypeFieldEntryTest::doFlagNode in Flag 8.4
Create a node and flag it.
1 call to LinkTypeFieldEntryTest::doFlagNode()
- LinkTypeFieldEntryTest::testCreateFieldEntryFlag in tests/
src/ Functional/ LinkTypeFieldEntryTest.php - Create a new flag with the Field Entry type, and add fields.
File
- tests/
src/ Functional/ LinkTypeFieldEntryTest.php, line 115
Class
- LinkTypeFieldEntryTest
- Test the Field Entry link type.
Namespace
Drupal\Tests\flag\FunctionalCode
public function doFlagNode() {
$node = $this
->drupalCreateNode([
'type' => $this->nodeType,
]);
$this->nodeId = $node
->id();
// Grant the flag permissions to the authenticated role, so that both
// users have the same roles and share the render cache.
$this
->grantFlagPermissions($this->flag);
// Create and login a new user.
$user_1 = $this
->drupalCreateUser();
$this
->drupalLogin($user_1);
// Click the flag link.
$this
->drupalGet('node/' . $this->nodeId);
$this
->clickLink($this->flag
->getShortText('flag'));
// Check if we have the confirm form message displayed.
$this
->assertText($this->flagConfirmMessage);
// Enter the field value and submit it.
$this->flagFieldValue = $this
->randomString();
$edit = [
'field_' . $this->flagFieldId . '[0][value]' => $this->flagFieldValue,
];
$this
->drupalPostForm(NULL, $edit, $this->createButtonText);
// Check that the node is flagged.
$this
->assertLink($this->flag
->getShortText('unflag'));
}