You are here

function dfpTokensTest::testUrlPartsToken in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 tests/dfp.test \dfpTokensTest::testUrlPartsToken()

File

tests/dfp_tokens.test, line 44
Tokens test file for DFP module.

Class

dfpTokensTest
@file Tokens test file for DFP module.

Code

function testUrlPartsToken() {

  // Create a tag that uses the url parts token in a target.
  $tag = $this
    ->createTag();
  $url = 'admin/structure/dfp_ads';
  $url_parts = explode('/', $url);
  $max_parts_to_test = 3;
  for ($i = 1; $i <= $max_parts_to_test; $i++) {
    $edit['targeting[0][target]'] = 'url parts';
    $edit['targeting[0][value]'] = '[dfp_tag:url_parts:' . $i . ']';
    $this
      ->editTag($tag->machinename, $edit);
    $this
      ->drupalGet($url);
    $replacement = implode('/', array_slice($url_parts, 0, $i));
    $this
      ->assertPropertySet('Targeting', 'url parts', $replacement);
  }
}