You are here

public function DisplayTagTest::testSlug in Doubleclick for Publishers (DFP) 8

Tests slug display.

File

tests/src/Functional/DisplayTagTest.php, line 87

Class

DisplayTagTest
Tests display of DFP ad tag.

Namespace

Drupal\Tests\dfp\Functional

Code

public function testSlug() {
  $this
    ->config('dfp.settings')
    ->set('hide_slug', FALSE)
    ->save();
  $edit = $this
    ->dfpBasicTagEditValues();

  // Create a tag without a slug, display it and ensure the default slug is
  // displayed.
  $edit['slug'] = '';
  $tag = $this
    ->dfpCreateTag($edit);
  $this
    ->drupalGet('<front>');
  $this
    ->assertText('Global DFP slug', 'The default slug is correctly used when no slug exists for an individual tag.');

  // Change the slug to <none> and ensure that no slug is displayed.
  $edit['slug'] = '<none>';
  $this
    ->dfpEditTag($tag
    ->id(), $edit);
  $this
    ->drupalGet('<front>');
  $this
    ->assertNoText('Global DFP slug', 'No slug is appearing when "<none>" is used.');

  // Specify a slug and check that it shows instead of the default slug.
  $edit['slug'] = 'Tag specific slug';
  $this
    ->dfpEditTag($tag
    ->id(), $edit);
  $this
    ->drupalGet('<front>');
  $this
    ->assertText('Tag specific slug');

  // Set the slug to be hidden. Use admin UI and the cache tags added in
  // \Drupal\dfp\View\TagViewBuilder::viewMultiple() are tested.
  $edit = [
    'hide_slug' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/structure/dfp/settings', $edit, t('Save configuration'));
  $this
    ->drupalGet('<front>');
  $this
    ->assertNoText('Tag specific slug');
}