public function LinkFieldCrudTest::testStaticLinkCreate in Link 7
Static Link Create.
Testing that if you use <strong> in a static title for your link, that the title actually displays <strong>.
File
- tests/
LinkFieldCrudTest.test, line 199 - Testing that users can not input bad URLs or labels.
Class
- LinkFieldCrudTest
- Testing that users can not input bad URLs or labels.
Code
public function testStaticLinkCreate() {
$this->web_user = $this
->drupalCreateUser(array(
'administer content types',
'administer fields',
'access content',
'create page content',
));
$this
->drupalLogin($this->web_user);
// Create field.
$name = strtolower($this
->randomName());
$field_name = 'field_' . $name;
$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][title]' => 'value',
'instance[settings][title_value]' => '<strong>' . $name . '</strong>',
), t('Save settings'));
// Is field created?
$this
->assertRaw(t('Saved %label configuration', array(
'%label' => $name,
)), 'Field added');
// Create page form.
$this
->drupalGet('node/add/page');
$this
->assertField($field_name . '[und][0][url]', 'URL found');
$input = array(
'href' => 'http://example.com/' . $this
->randomName(),
);
$edit = array(
'title' => $name,
$field_name . '[und][0][url]' => $input['href'],
);
$this
->drupalPost(NULL, $edit, t('Save'));
$url = $this
->getUrl();
// Change to anonymous user.
$this
->drupalLogout();
$this
->drupalGet($url);
$this
->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array(
'html' => TRUE,
)));
}