You are here

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

Tests Adsense backfill settings.

File

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

Class

DisplayTagTest
Tests display of DFP ad tag.

Namespace

Drupal\Tests\dfp\Functional

Code

public function testBackfill() {
  $edit = $this
    ->dfpBasicTagEditValues();

  // Create a tag with backfill settings.
  $colors = [
    'background',
    'border',
    'link',
    'text',
    'url',
  ];
  $edit['adsense_backfill[ad_types]'] = 'text_image';
  $edit['adsense_backfill[channel_ids]'] = $this
    ->randomMachineName();
  foreach ($colors as $color) {
    $edit['adsense_backfill[color][' . $color . ']'] = mb_strtoupper($this
      ->randomMachineName(6));
  }
  $this
    ->dfpCreateTag($edit);
  $this
    ->drupalGet('<front>');
  $this
    ->assertPropertySet('', 'adsense_ad_types', $edit['adsense_backfill[ad_types]']);
  $this
    ->assertPropertySet('', 'adsense_channel_ids', $edit['adsense_backfill[channel_ids]']);
  foreach ($colors as $color) {
    $this
      ->assertPropertySet('', 'adsense_' . $color . '_color', '#' . $edit['adsense_backfill[color][' . $color . ']']);
  }
}