function LinkAttributeCrudTest::test_rel_nofollow_on_external_link in Link 6.2
File
- tests/
link.attribute.test, line 569 - Basic simpletests to test options on link module.
Class
Code
function test_rel_nofollow_on_external_link() {
$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,
'attributes[rel]' => 'nofollow',
), t('Save field settings'));
// Is field created?
$this
->assertRaw(t('Added field %label.', array(
'%label' => $name,
)), 'Field added');
// create page form
$this
->drupalGet('node/add/page');
$this
->assertField($field_name . '[0][url]', 'URL found');
$input = array(
'href' => 'http://example.com/' . $this
->randomName(),
);
$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, $input['href'], array(
'attributes' => array(
'rel' => 'nofollow',
),
)));
}