You are here

public function LinkOutputLocationTest::testNoLinkLocation in Flag 8.4

Tests that when no display types are selected, no flag links appear.

File

tests/src/Functional/LinkOutputLocationTest.php, line 144

Class

LinkOutputLocationTest
Tests the Flag link is output in various locations.

Namespace

Drupal\Tests\flag\Functional

Code

public function testNoLinkLocation() {
  $flag_config = $this->flag
    ->getFlagTypePlugin()
    ->getConfiguration();
  $flag_config['show_as_field'] = FALSE;
  $flag_config['show_in_links'] = [];
  $flag_config['show_on_form'] = FALSE;
  $flag_config['show_contextual_link'] = FALSE;
  $this->flag
    ->getFlagTypePlugin()
    ->setConfiguration($flag_config);
  $this->flag
    ->save();
  $contextual_links_id = 'node:node=' . $this->node
    ->id() . ':changed=' . $this->node
    ->getChangedTime() . '&flag_keys=' . $this->flag
    ->id() . '-flag&langcode=en';
  $this
    ->drupalGet('node');
  $this
    ->assertNoPseudofield($this->flag, $this->node);
  $this
    ->assertNoContextualLinkPlaceholder($contextual_links_id);
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertNoPseudofield($this->flag, $this->node);
  $this
    ->assertNoContextualLinkPlaceHolder($contextual_links_id);

  // TODO: check no entity field link.
  $this
    ->drupalGet('node/' . $this->node
    ->id() . '/edit');
  $this
    ->assertNoField('flag[' . $this->flag
    ->id() . ']');
  $this
    ->assertNoContextualLinkPlaceholder($contextual_links_id);
}