You are here

dfp_ads.test in Doubleclick for Publishers (DFP) 7

Ads test file for DFP module.

File

tests/dfp_ads.test
View source
<?php

/**
 * @file
 * Ads test file for DFP module.
 */
class dfpAdTestTest extends dfpBaseTest {

  /**
   * Implements getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Displaying AdTest DFP Tags'),
      'description' => t('Tests for displaying overridden DFP tags for ad test purposes.'),
      'group' => t('DFP'),
    );
  }
  function testTestPage() {
    $tag = $this
      ->createTag();
    $override = $this
      ->randomName(8);
    $this
      ->drupalGet('admin/structure/dfp_ads/test_page', array(
      'query' => array(
        'adunit_override' => $override,
      ),
    ));
    $this
      ->assertRaw('googletag.defineSlot("' . variable_get('dfp_network_id', '') . '/' . $override . '"', 'The Ad Unit Name was properly overridden on the Ad Test Page.');
  }
  function testQueryString() {
    $tag = $this
      ->createTag();
    $override = $this
      ->randomName(8);
    variable_set('dfp_adtest_adunit', $override);
    $this
      ->drupalGet('admin/structure/dfp_ads/test_page', array(
      'query' => array(
        'adtest' => 'true',
      ),
    ));
    $this
      ->assertRaw('googletag.defineSlot("' . variable_get('dfp_network_id', '') . '/' . $override . '"', 'The Ad Unit Name was properly overridden using the adtest query string.');

    // Check that nefarious override values are caught because security.
    $nefarious_override = "<script>alert('not safe');</script>";
    $this
      ->drupalGet('admin/structure/dfp_ads/test_page', array(
      'query' => array(
        'adunit_override' => $nefarious_override,
      ),
    ));
    $this
      ->assertNoRaw($nefarious_override, 'Only strings without executable code can be used for the adunit_override query string.');
  }

}

Classes

Namesort descending Description
dfpAdTestTest @file Ads test file for DFP module.