1.20.x link.ui.test LinkUITest::testStaticLinkCreate()

Testing that if you use <strong> in a static title for your link, that the title actually displays <strong>.

File

modules/link/tests/link.ui.test, line 144
Testing CRUD API in the browser.

Class

LinkUITest
Testing that users can not input bad URLs or labels

Code

function testStaticLinkCreate() {
  $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->backdropPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
  $this->backdropPost(NULL, array(
    'instance[settings][title]' => 'value',
    'instance[settings][title_value]' => '<strong>' . $name . '</strong>'), t('Save settings')
  );

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

  $this->backdropGet('node/add/page');
  $this->assertField($field_name . '[und][0][url]', 'URL found');

  $input = array(
    'href' => 'http://example.com/' . $this->randomName()
  );

  $edit = array(
    'title' => $name,
    $field_name . '[und][0][url]' => $input['href'],
  );
  $this->backdropPost(NULL, $edit, t('Save'));

  $this->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array('html' => TRUE)));
}