public function FlagContextualLinksTest::setUp in Flag 8.4
Overrides BrowserTestBase::setUp
File
- tests/
src/ FunctionalJavascript/ FlagContextualLinksTest.php, line 91
Class
- FlagContextualLinksTest
- Test the contextual links with Reload link type.
Namespace
Drupal\Tests\flag\FunctionalJavascriptCode
public function setUp() {
parent::setUp();
// Get the Flag Service.
$this->flagService = $this->container
->get('flag');
// Create content type.
$this
->drupalCreateContentType([
'type' => $this->nodeType,
]);
// Create the admin user.
$this->adminUser = $this
->createUser([
'administer flags',
'administer flagging display',
'administer flagging fields',
'administer node display',
'administer modules',
'administer nodes',
'create ' . $this->nodeType . ' content',
'edit any ' . $this->nodeType . ' content',
'delete any ' . $this->nodeType . ' content',
'access contextual links',
'access content',
'access toolbar',
]);
// Create a regular user who will be flagging content.
$this->alice = $this
->drupalCreateUser([
'create ' . $this->nodeType . ' content',
'edit any ' . $this->nodeType . ' content',
'delete any ' . $this->nodeType . ' content',
'access contextual links',
'access content',
'access toolbar',
]);
// Create a second regular user who will be flagging content.
$this->bob = $this
->drupalCreateUser([
'create ' . $this->nodeType . ' content',
'edit any ' . $this->nodeType . ' content',
'delete any ' . $this->nodeType . ' content',
'access contextual links',
'access content',
'access toolbar',
]);
$this
->drupalLogin($this->adminUser);
// Create flag with a Reload link type and enable contextual links display.
$this->flag = Flag::create([
'id' => 'test_label_123',
'label' => $this
->randomHTMLString(),
'entity_type' => 'node',
'bundles' => array_keys(\Drupal::service('entity_type.bundle.info')
->getBundleInfo('node')),
'flag_short' => $this
->randomHTMLString(),
'unflag_short' => $this
->randomHTMLString(),
'unflag_denied_text' => $this
->randomHTMLString(),
'flag_long' => $this
->randomHTMLString(16),
'unflag_long' => $this
->randomHTMLString(16),
'flag_message' => $this
->randomHTMLString(32),
'unflag_message' => $this
->randomHTMLString(32),
'flag_type' => $this
->getFlagType('node'),
'link_type' => 'reload',
'flagTypeConfig' => [
'show_as_field' => FALSE,
'show_on_form' => FALSE,
'show_contextual_link' => TRUE,
],
'linkTypeConfig' => [],
'global' => FALSE,
]);
$this->flag
->save();
// Grant the flag permissions to the authenticated role.
$this
->grantFlagPermissions($this->flag);
}