You are here

function LinkAttributeCrudTest::test_rel_nofollow_bug in Link 6.2

This test exercises the bugfix for http://drupal.org/node/628902. It's also making sure that if you set up a link field with 'rel="nofollow"' and point it internally, then the link does not show rel="nofollow".

File

tests/link.attribute.test, line 524
Basic simpletests to test options on link module.

Class

LinkAttributeCrudTest

Code

function test_rel_nofollow_bug() {
  $account = $this
    ->drupalCreateUser(array(
    'administer content types',
    'access content',
    'create page content',
  ));
  $this
    ->drupalLogin($account);

  // create field
  $name = strtolower($this
    ->randomName());
  $field_name = 'field_' . $name;
  $edit = array(
    '_add_new_field[label]' => $name,
    '_add_new_field[field_name]' => $name,
    '_add_new_field[type]' => 'link',
    '_add_new_field[widget_type]' => 'link',
  );
  $this
    ->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
  $this
    ->drupalPost(NULL, array(
    'title' => 'value',
    'title_value' => $name,
    'attributes[rel]' => 'nofollow',
  ), t('Save field settings'));

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

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

  // change to anonymous user
  $this
    ->drupalLogout();
  $this
    ->drupalGet($url);

  //$this->pass($this->content);
  $this
    ->assertRaw(l($name, 'test'));

  //, array('attributes' => array('rel' => ''))));
}