You are here

function LinkAttributeCrudTest::testLinkWithNoFollowOnFieldTargetNewWindowAndAClass in Link 6.2

Trying to reproduce exactly what's in issue #664990

http://drupal.org/node/664990

File

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

Class

LinkAttributeCrudTest

Code

function testLinkWithNoFollowOnFieldTargetNewWindowAndAClass() {
  $this
    ->acquireContentTypes(1);
  $field_settings = array(
    'type' => 'link',
    'widget_type' => 'link',
    'type_name' => $this->content_types[0]->name,
    'attributes' => array(
      'class' => 'testlink',
      'target' => LINK_TARGET_NEW_WINDOW,
      'rel' => 'nofollow',
    ),
  );
  $field = $this
    ->createField($field_settings, 0);

  //$this->pass('<pre>'. print_r($field, TRUE) .'</pre>');
  $field_db_info = content_database_info($field);
  $this
    ->acquireNodes(2);
  $node = node_load($this->nodes[0]->nid);
  $node->promote = 1;

  // We want this to show on front page for the teaser test.
  $node->{$field['field_name']}[0] = $this
    ->createLink('http://www.example.com', 'Test Link');
  node_save($node);

  // Does this display on the node page?
  $this
    ->drupalGet('node/' . $this->nodes[0]->nid);

  //$this->outputScreenContents('Link field with class', 'link_');
  $this
    ->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array(
    'attributes' => array(
      'class' => 'testlink',
      'target' => '_blank',
      'rel' => 'nofollow',
    ),
  )));

  //$this->pass($this->content);

  // Does this display on the front page?
  $this
    ->drupalGet('<front>');

  // reset the zebra!
  $this->zebra = 0;
  $this
    ->assertLinkOnNode($field['field_name'], l('Test Link', 'http://www.example.com', array(
    'attributes' => array(
      'class' => 'testlink',
      'target' => '_blank',
      'rel' => 'nofollow',
    ),
  )));
}