You are here

public function LinkFieldValidateTest::testLinkValidateBadUrlValidateDefault in Link 7

Test if we're stopped from posting a bad url on default validation.

File

tests/LinkFieldValidateTest.test, line 71
Link field Validation Tests.

Class

LinkFieldValidateTest
Link field Validation Tests.

Code

public function testLinkValidateBadUrlValidateDefault() {
  $this->web_user = $this
    ->drupalCreateUser(array(
    'administer content types',
    'administer fields',
    'administer nodes',
    'administer filters',
    'access content',
    'create page content',
    'access administration pages',
  ));
  $this
    ->drupalLogin($this->web_user);

  // Create field.
  $name = strtolower($this
    ->randomName());
  $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
    ->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
  $this
    ->drupalPost(NULL, array(), t('Save field settings'));
  $this
    ->drupalPost(NULL, array(), t('Save settings'));

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

  // Create page form.
  $this
    ->drupalGet('node/add/page');
  $field_name = 'field_' . $name;
  $this
    ->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
  $this
    ->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
  $edit = array(
    'title' => 'Simple Title',
    $field_name . '[und][0][url]' => 'edik:naw',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->assertText(t('The value @value provided for @field is not a valid URL.', array(
    '@value' => 'edik:naw',
    '@field' => $name,
  )));
}