function NofollowListTestCase::testNoRelFollowOnWhitelist in Nofollow List 7
Tests whitelist functionality.
Tests that:
- rel="nofollow" is not added to links that are on the whitelist.
- rel="nofollow" is not added to internal links.
- rel="nofollow" is added to links that are not on the whitelist.
File
- ./
nofollowlist.test, line 63 - Tests for nofollowlist.module.
Class
- NofollowListTestCase
- Tests the rel="nofollow" whitelist functionality.
Code
function testNoRelFollowOnWhitelist() {
$this
->setupNofollowlist('white', "drupal.org\nwww.drupal.org");
// Add page.
$this
->drupalGet('node/add/page');
$edit = array();
$edit['title'] = $this
->randomName(8);
// Add drupal.org link.
$body_text = '<a href="http://drupal.org">drupal.org</a>';
// Add www.drupal.org link.
$body_text .= '<a href="http://www.drupal.org">wwwdrupal.org</a>';
// Add internal link.
$body_text .= '<a href="/drupal.org">internal link to drupal</a>';
// Add external link.
$body_text .= '<a href="http://www.example.com">example.com</a>';
$edit['body[und][0][value]'] = $body_text;
// Full html text format.
$edit['body[und][0][format]'] = 'full_html';
$this
->drupalPost('node/add/page', $edit, t('Save'));
// Check that drupal.org link does not have a rel="nofollow".
$this
->assertPattern('|<a href="http://drupal.org">drupal.org</a>|', 'Drupal.org link does not have rel="nofollow".');
// Check that www.drupal.org does not have a rel="nofollow".
$this
->assertPattern('|<a href="http://www.drupal.org">wwwdrupal.org</a>|', 'Www.drupal.org link does not have rel="nofollow".');
// Check that drupal internal link does not hav a rel="nofollow".
$this
->assertPattern('|<a href="/drupal.org">internal link to drupal</a>|', 'Internal link does not have rel="nofollow".');
// Check that example.com has a rel=nofollow.
$this
->assertPattern('|<a href="http://www.example.com" rel="nofollow">example.com</a>|', 'Example.com link does not have rel="nofollow".');
}