function LinkAttributeCrudTest::test_bad_attributes_bugfix_string_attributes 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 673 - Basic simpletests to test options on link module.
Class
Code
function test_bad_attributes_bugfix_string_attributes() {
$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 set $field['attributes'] equal to a string of length 0.
db_query("UPDATE {content_node_field} SET global_settings = '%s' WHERE field_name = '%s'", 'a:6:{s:10:"attributes";s:0:"";s:7:"display";a:1:{s:10:"url_cutoff";s:2:"80";}s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:0:"";s:13:"enable_tokens";i:1;}', $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' => ''))));
}