You are here

public function LinkTokenTest::testCRUDTitleOnlyTitleNoLink2 in Link 7

CRUD Title Only Title No Link.

Test that if you have a title and no url on a field which does not have tokens enabled, that the title is sanitized once.

@codingStandardsIgnoreStart

File

tests/LinkTokenTest.test, line 415
Testing that tokens can be used in link titles.

Class

LinkTokenTest
Testing that tokens can be used in link titles.

Code

public function testCRUDTitleOnlyTitleNoLink2() {

  //@codingStandardsIgnoreEnd
  $this->web_user = $this
    ->drupalCreateUser(array(
    'administer content types',
    'administer fields',
    'access content',
    'create page content',
  ));
  $this
    ->drupalLogin($this->web_user);

  // Create field.
  $name = strtolower($this
    ->randomName());
  $field_name = 'field_' . $name;
  $edit = array(
    'fields[_add_new_field][label]' => $name,
    'fields[_add_new_field][field_name]' => $name,
    'fields[_add_new_field][type]' => 'link_field',
    'fields[_add_new_field][widget_type]' => 'link_field',
  );
  $this
    ->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
  $this
    ->drupalPost(NULL, array(), t('Save field settings'));
  $this
    ->drupalPost(NULL, array(
    'instance[settings][url]' => 1,
    'instance[settings][enable_tokens]' => 0,
  ), t('Save settings'));

  // Is field created?
  $this
    ->assertRaw(t('Saved %label configuration', array(
    '%label' => $name,
  )), 'Field added');

  // Create page form.
  $this
    ->drupalGet('node/add/page');
  $this
    ->assertField($field_name . '[und][0][url]', 'URL found');
  $input = array(
    'title' => 'This & That',
    'href' => '',
  );
  $edit = array(
    'title' => $name,
    $field_name . '[und][0][title]' => $input['title'],
    $field_name . '[und][0][url]' => $input['href'],
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $url = $this
    ->getUrl();

  // Change to anonymous user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet($url);
  $this
    ->assertRaw('This & That');
}