You are here

function LinkAttributeCrudTest::test_Link_With_Title_Attribute_WithNoFollowOnFieldTargetNewWindowAndAClass_Form in Link 6.2

Another test for http://drupal.org/node/664990

File

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

Class

LinkAttributeCrudTest

Code

function test_Link_With_Title_Attribute_WithNoFollowOnFieldTargetNewWindowAndAClass_Form() {
  $this
    ->acquireContentTypes(1);
  $field_settings = array(
    'type' => 'link',
    'widget_type' => 'link',
    'type_name' => $this->content_types[0]->name,
    'attributes' => array(
      'class' => '',
      'target' => 'default',
      'rel' => 'nofollow',
      'title' => '',
    ),
  );
  $field = $this
    ->createField($field_settings, 0);
  $field_db_info = content_database_info($field);
  $url_type = str_replace('_', '-', $this->content_types[0]->type);
  $edit = array();
  $edit['attributes[class]'] = 'testdata';
  $edit['attributes[target]'] = LINK_TARGET_NEW_WINDOW;
  $edit['attributes[rel]'] = 'nofollow';
  $this
    ->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
  $this
    ->assertText(t('Saved field @field_name', array(
    '@field_name' => $field['field_name'],
  )));

  // So, having saved this field_name, let's see if it works...
  $this
    ->acquireNodes(1);
  $node = node_load($this->nodes[0]->nid);
  $this
    ->drupalGet('node/' . $this->nodes[0]->nid);
  $edit = array();
  $edit[$field['field_name'] . '[0][url]'] = 'http://www.example.com/test';
  $title = 'title_' . $this
    ->randomName(20);
  $edit[$field['field_name'] . '[0][title]'] = $title;
  $this
    ->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));

  // Make sure we get a new version!
  $node = node_load($this->nodes[0]->nid, NULL, TRUE);
  $this
    ->assertText(t('@type @title has been updated.', array(
    '@title' => $node->title,
    '@type' => $this->content_types[0]->name,
  )));
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertText($title, 'Make sure the link title/text shows');

  //$this->assertRaw(' title="test_data"', "Do we show the title?");
  $this
    ->assertLinkOnNode($field['field_name'], l($title, 'http://www.example.com/test', array(
    'attributes' => array(
      'target' => '_blank',
      'rel' => 'nofollow',
      'class' => 'testdata',
    ),
  )));

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