You are here

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

Tests display a DFP tag in a block.

File

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

Class

DisplayTagTest
Tests display of DFP ad tag.

Namespace

Drupal\Tests\dfp\Functional

Code

public function testDisplayTag() {

  // Create a simple tag as a block.
  $tag = $this
    ->dfpCreateTag();
  $tag_view = $this
    ->dfpTagToTagView($tag);
  $this
    ->drupalGet('<front>');
  $this
    ->assertRaw('googletag.defineSlot("' . $tag_view
    ->getAdUnit() . '", ' . $tag_view
    ->getSize() . ', "' . $tag_view
    ->getPlaceholderId() . '")');

  // Create a tag with an ID longer than 32 characters.
  $edit = [
    'id' => mb_strtolower($this
      ->randomMachineName(64)),
  ];
  $tag = $this
    ->dfpCreateTag($edit);
  $tag_view = $this
    ->dfpTagToTagView($tag);
  $this
    ->drupalGet('<front>');
  $this
    ->assertRaw('googletag.defineSlot("' . $tag_view
    ->getAdUnit() . '", ' . $tag_view
    ->getSize() . ', "' . $tag_view
    ->getPlaceholderId() . '")');
}