public function LinkFieldValidateTest::testLinkValidateBadUrlValidateOff in Link 7
Test if we can post a bad url if the validation is expressly turned off.
File
- tests/
LinkFieldValidateTest.test, line 172 - Link field Validation Tests.
Class
- LinkFieldValidateTest
- Link field Validation Tests.
Code
public function testLinkValidateBadUrlValidateOff() {
$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(
'instance[settings][validate_url]' => FALSE,
), t('Save settings'));
// @codingStandardsIgnoreLine
/*$instance_details = db_query("SELECT * FROM {field_config_instance} WHERE field_name = :field_name AND bundle = 'page'", array(':field_name' => 'field_'. $name))->fetchObject();
$this->fail('<pre>'. print_r($instance_details, TRUE) .'</pre>');
$this->fail('<pre>'. print_r(unserialize($instance_details->data), TRUE) .'</pre>');*/
// 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
->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
'%field' => $name,
'%value' => 'edik:naw',
)));
}