You are here

function URLFieldTestCase::testURLFieldCreation in URL field 7

Test URL field creation from the UI.

File

./url.test, line 199
Tests for url.module.

Class

URLFieldTestCase
Tests for URL field types.

Code

function testURLFieldCreation() {

  // Display the "Add content type" form.
  $this
    ->drupalGet('admin/structure/types/add');

  // Add a content type.
  $name = $this
    ->randomName();
  $type = drupal_strtolower($name);
  $edit = array(
    'name' => $name,
    'type' => $type,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save and add fields'));

  // Add an URL field to the newly-created type.
  $label = $this
    ->randomName();
  $field_name = drupal_strtolower($label);
  $edit = array(
    'fields[_add_new_field][label]' => $label,
    'fields[_add_new_field][field_name]' => $field_name,
    'fields[_add_new_field][type]' => 'url',
    'fields[_add_new_field][widget_type]' => 'url_external',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Load the formatter page to check that the settings summary does not
  // generate warnings.
  // @todo Mess with the formatter settings a bit here.
  $this
    ->drupalGet("admin/structure/types/manage/{$type}/display");
}