You are here

dfp_globals.test in Doubleclick for Publishers (DFP) 7

Globals test file for DFP module.

File

tests/dfp_globals.test
View source
<?php

/**
 * @file
 * Globals test file for DFP module.
 */
class dfpGlobalsTest extends dfpBaseTest {

  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Global DFP Tag Settings'),
      'description' => t('Tests for the settings defined in admin/structure/dfp_ads/settings.'),
      'group' => t('DFP'),
    );
  }
  function testGlobalSettingsOn() {
    $injected_js = $this
      ->randomName(32);
    $target = array(
      'target' => $this
        ->randomName(8),
      'value' => $this
        ->randomName(8),
    );
    variable_set('dfp_async_rendering', '1');
    variable_set('dfp_single_request', '1');
    variable_set('dfp_collapse_empty_divs', '1');
    variable_set('dfp_injected_js', $injected_js);
    variable_set('dfp_targeting', array(
      $target,
    ));
    $this
      ->drupalGet('/');
    $this
      ->assertRaw('googletag.pubads().enableAsyncRendering();', 'Asyncronous rendering is turned on.');
    $this
      ->assertRaw('googletag.pubads().enableSingleRequest();', 'Single request is turned on.');
    $this
      ->assertRaw('googletag.pubads().collapseEmptyDivs();', 'Collapse empty divs is turned on.');
    $this
      ->assertRaw($injected_js, 'Injected javascript correctly appears on the page.');
    $this
      ->assertRaw('googletag.pubads().setTargeting("' . $target['target'] . '", "' . $target['value'] . '");', 'Global targeting values appear correctly in javascript.');
  }
  function testGlobalSettingsOff() {
    variable_set('dfp_async_rendering', '0');
    variable_set('dfp_single_request', '0');
    variable_set('dfp_collapse_empty_divs', '0');
    $this
      ->drupalGet('/');
    $this
      ->assertNoRaw('googletag.pubads().enableAsyncRendering();', 'Asyncronous rendering is turned off.');
    $this
      ->assertNoRaw('googletag.pubads().enableSingleRequest();', 'Single request is turned off.');
    $this
      ->assertNoRaw('googletag.pubads().collapseEmptyDivs();', 'Collapse empty divs is turned off.');
  }

}

Classes

Namesort descending Description
dfpGlobalsTest @file Globals test file for DFP module.