You are here

public function LinkTokenTest::xTestLinkWithTitleAttributeTokenUrlForm in Link 7

This test doesn't seem to actually work, due to lack of 'title' in url.

@codingStandardsIgnoreStart

File

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

Class

LinkTokenTest
Testing that tokens can be used in link titles.

Code

public function xTestLinkWithTitleAttributeTokenUrlForm() {

  /* $this->loginWithPermissions($this->permissions);
      $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);
      //$this->fail('<pre>'. print_r($field, TRUE) .'</pre>');
      $field_name = $field['field_name'];
      $field_db_info = content_database_info($field);
      $url_type = str_replace('_', '-', $this->content_types[0]->type);

      $edit = array('attributes[title]' => '['. $field_name .'-url]',
      'enable_tokens' => TRUE);
      // @codingStandardsIgnoreLine
      $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'])));*/

  // @codingStandardsIgnoreEnd
  $name = $this
    ->randomName();
  $settings = array(
    'instance[settings][attributes][rel]' => 'nofollow',
  );
  $field_name = $this
    ->createLinkField('page', $settings);

  // 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();
  $test_link_url = 'http://www.example.com/test';
  $edit[$field_name . '[und][0][url]'] = $test_link_url;
  $title = 'title_' . $this
    ->randomName(20);
  $edit[$field_name . '[und][0][title]'] = $title;
  $edit['title'] = $name;
  $this
    ->drupalGet('node/add/page');
  $this
    ->drupalPost(NULL, $edit, t('Save'));

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

  // $this->drupalGet('node/'. $node->nid);.
  $this
    ->assertText($title, 'Make sure the link title/text shows');
  $this
    ->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
  $this
    ->assertNoRaw(' title="[' . $field_name . '-url]"');
  $this
    ->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));

  // $this->fail($this->content);.
}