You are here

function dfpAdTestTest::testQueryString in Doubleclick for Publishers (DFP) 7.2

Same name and namespace in other branches
  1. 7 tests/dfp_ads.test \dfpAdTestTest::testQueryString()

File

tests/dfp.test, line 517
Test file for DFP module.

Class

dfpAdTestTest

Code

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 overrride 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.');
}