function dfpAdCategoriesTest::testDisplayAdCategories in Doubleclick for Publishers (DFP) 7
Same name and namespace in other branches
- 7.2 tests/dfp.test \dfpAdCategoriesTest::testDisplayAdCategories()
File
- tests/
dfp_ad_categories.test, line 56 - Ad Categories test file for DFP module.
Class
- dfpAdCategoriesTest
- @file Ad Categories test file for DFP module.
Code
function testDisplayAdCategories() {
$dfp_add_categories_vocabulary = taxonomy_vocabulary_machine_name_load('dfp_ad_categories');
$tags_vocabulary = taxonomy_vocabulary_machine_name_load('tags');
// Turn on DFP ad categories for the "tags" vocabulary.
$edit = array(
'dfp_enable_ad_categories' => 1,
'dfp_enable_ad_categories_bundles[tags]' => 'tags',
);
$this
->drupalPost('admin/structure/dfp_ads/settings', $edit, t('Save configuration'));
// Create a new DFP Ad Category term.
$dfp_category = $this
->createTerm($dfp_add_categories_vocabulary);
$control_tag = $this
->createTerm($tags_vocabulary);
$test_tag = $this
->createTerm($tags_vocabulary);
// Create a new "Article" node with these two tags.
$edit = array(
'title' => $this
->randomName(8),
'field_tags[und]' => $control_tag->name . ', ' . $test_tag->name,
);
$this
->drupalPost('node/add/article', $edit, t('Save'));
// Edit one the new tags and tag it with a DFP Ad Category.
$edit = array(
'field_dfp_ad_categories[und]' => $dfp_category->tid,
);
$this
->drupalPost('taxonomy/term/' . $test_tag->tid . '/edit', $edit, t('Save'));
// Create a DFP ad slot that targets the [dfp_tag:ad_categories] token.
$edit = $this
->dfpBasicTagEditValues();
// Create a tag that uses the slot token in a target.
$edit['slot'] = $this
->randomName(8);
$edit['targeting[0][target]'] = 'categories';
$edit['targeting[0][value]'] = '[dfp_tag:ad_categories]';
$tag = $this
->createTag($edit);
// Check that when we are on the node page, that the DFP Ad Category is used
// and that the control tag is also displayed.
$this
->drupalGet('node/1');
$this
->assertPropertySet('Targeting', 'categories', $control_tag->name);
$this
->assertPropertySet('Targeting', 'categories', $dfp_category->name);
// Check that when we are on the term page for one of DFP Ad Categories that
// it is correctly included.
$this
->drupalGet('taxonomy/term/' . $dfp_category->tid);
$this
->assertPropertySet('Targeting', 'categories', $dfp_category->name);
// Check that when we are on a term page for a term with a corresponding
// DFP Ad Categories the DFP Ad Category is included.
$this
->drupalGet('taxonomy/term/' . $test_tag->tid);
$this
->assertPropertySet('Targeting', 'categories', $dfp_category->name);
}