function dfpDisplayTagTest::testDisplayTag in Doubleclick for Publishers (DFP) 7
Same name and namespace in other branches
- 7.2 tests/dfp.test \dfpDisplayTagTest::testDisplayTag()
File
- tests/
dfp_display_tag.test, line 20 - Display tag test file for DFP module.
Class
- dfpDisplayTagTest
- @file Display tag test file for DFP module.
Code
function testDisplayTag() {
// Create a simple tag as a block.
$tag = $this
->createTag();
$this
->assertRaw('googletag.defineSlot("' . variable_get('dfp_network_id', '') . '/' . $tag->adunit . '", ' . dfp_format_size($tag->size) . ', "' . $tag->placeholder_id . '")', 'The ad slot has been correctly defined in javascript.');
// Create a tag with a machine name longer than 32 characters.
$edit = array(
'machinename' => drupal_strtolower($this
->randomName(64)),
);
$tag = $this
->createTag($edit);
$this
->assertRaw('googletag.defineSlot("' . variable_get('dfp_network_id', '') . '/' . $tag->adunit . '", ' . dfp_format_size($tag->size) . ', "' . $tag->placeholder_id . '")', 'The ad slot with a very long machine name has been correctly defined in javascript.');
// Ensure the DPF click url is safe.
variable_set('dfp_click_url', 'javascript://example.com?foo&bar');
$this
->drupalGet('/');
$this
->assertNoRaw('javascript://example.com');
$pattern = '|.setClickUrl\\("http(.*):\\/\\/(.*)javascript%3A\\/\\/example.com%3Ffoo%26bar"\\)|';
$this
->assertPattern($pattern, 'Click URL is filtered for bad protocols and absolute.');
variable_set('dfp_click_url', 'http://example.com?foo&bar');
$this
->drupalGet('/');
$this
->assertRaw('.setClickUrl("http://example.com?foo&bar")', 'Valid external Click URL is not mangled.');
}