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

Testing that if you have the title but no URL, the title is not sanitized twice.

File

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

Class

LinkUITest
Testing that users can not input bad URLs or labels

Code

function testCRUDTitleOnlyTitleNoLink() {
  $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][url]' => 1,
  ), 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(
    'title' => 'This & That',
    'href' => '',
  );

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

  $this->assertRaw('This & That');
}