function dfpDisplayTagTest::testDisplayTagWithMapping in Doubleclick for Publishers (DFP) 7        
                          
                  
                        Same name and namespace in other branches
- 7.2 tests/dfp.test \dfpDisplayTagTest::testDisplayTagWithMapping()
File
 
   - tests/dfp_display_tag.test, line 42
- Display tag test file for DFP module.
Class
  
  - dfpDisplayTagTest 
- @file
Display tag test file for DFP module.
Code
function testDisplayTagWithMapping() {
  $edit = $this
    ->dfpBasicTagEditValues();
  
  $tag = $this
    ->createTag($edit);
  $mapping_sizes = explode(',', $edit['breakpoints[0][ad_sizes]']);
  $size_count = count($mapping_sizes);
  
  $mapping_tag = '.addSize(';
  $mapping_tag .= '[' . str_replace('x', ', ', $edit['breakpoints[0][browser_size]']) . '], ';
  $mapping_tag .= $size_count > 1 ? '[' : '';
  for ($i = 0; $i < $size_count; $i++) {
    $mapping_sizes[$i] = '[' . str_replace('x', ', ', $mapping_sizes[$i]) . ']';
    $mapping_tag .= $i + 1 !== $size_count ? $mapping_sizes[$i] . ', ' : $mapping_sizes[$i];
  }
  $mapping_tag .= $size_count > 1 ? '])' : ')';
  $this
    ->assertRaw('googletag.sizeMapping()', 'The ad slot correctly attaches size mapping.');
  $this
    ->assertRaw('.defineSizeMapping(mapping)', 'The ad slot correctly defines size mapping.');
  $this
    ->assertRaw($mapping_tag, 'The ad slot correctly defines specific size mappings.');
  
  $edit['breakpoints[0][browser_size]'] = $this
    ->randomName(8);
  $this
    ->editTag($tag->machinename, $edit);
  $this
    ->assertText(t('The browser size can only contain numbers and the character x.'), 'An error was correctly thrown when invalid characters.');
  
  $edit['breakpoints[0][browser_size]'] = $this
    ->dfpGenerateSize();
  $edit['breakpoints[0][ad_sizes]'] = $this
    ->randomName(8);
  $this
    ->editTag($tag->machinename, $edit);
  $this
    ->assertText(t('The ad size(s) string can only contain numbers, the character x and commas (unless it is the special keyword "!none").', array(
    '!none' => htmlspecialchars('<none>'),
  )), 'An error was correctly thrown when the Ad Size(s) field contained an invalid pattern.');
  
  $edit['breakpoints[0][browser_size]'] = '0x0';
  $edit['breakpoints[0][ad_sizes]'] = '<none>';
  $this
    ->editTag($tag->machinename, $edit);
  $this
    ->drupalGet('');
  $this
    ->assertRaw('addSize([0, 0], [])');
}