function LinkAttributeCrudTest::test_bad_attributes_bugfix_null_global_settings in Link 6.2
Here we test the fix to #626932, where an empty or bad attributes value on the link at the field level would cause the site to die in _link_sanitize, when the non-array $field['attributes'] is added to another array.
File
- tests/
link.attribute.test, line 619 - Basic simpletests to test options on link module.
Class
Code
function test_bad_attributes_bugfix_null_global_settings() {
$account = $this
->drupalCreateUser(array(
'administer content types',
'access content',
'create page content',
));
$this
->drupalLogin($account);
// create field
$name = strtolower($this
->randomName());
$field_name = 'field_' . $name;
$edit = array(
'_add_new_field[label]' => $name,
'_add_new_field[field_name]' => $name,
'_add_new_field[type]' => 'link',
'_add_new_field[widget_type]' => 'link',
);
$this
->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
$this
->drupalPost(NULL, array(
'title' => 'value',
'title_value' => $name,
), t('Save field settings'));
// Is field created?
$this
->assertRaw(t('Added field %label.', array(
'%label' => $name,
)), 'Field added');
// ruin the stored data in content_node_field.
// Here we replace the entire $field with a blank. The structure of the table
// prevents it from being set to a null, sadly.
db_query("UPDATE {content_node_field} SET global_settings = '' WHERE field_name = '%s'", $field_name);
// create page form
$this
->drupalGet('node/add/page');
$this
->assertField($field_name . '[0][url]', 'URL found');
$input = array(
'href' => 'test',
);
$edit = array(
'title' => $name,
$field_name . '[0][url]' => $input['href'],
);
$this
->drupalPost(NULL, $edit, t('Save'));
$url = $this
->getUrl();
// change to anonymous user
$this
->drupalLogout();
$this
->drupalGet($url);
//$this->pass($this->content);
$this
->assertRaw(l($name, 'test'));
//, array('attributes' => array('rel' => ''))));
}