| 7 filter.test | FilterUnitTestCase::testNoFollowFilter() |
| 8 filter.test | FilterUnitTestCase::testNoFollowFilter() |
Test the spam deterrent.
File
- modules/
filter/ filter.test, line 1121 - Tests for filter.module.
Code
function testNoFollowFilter() {
// Setup dummy filter object.
$filter = new stdClass();
$filter->settings = array(
'allowed_html' => '<a>',
'filter_html_help' => 1,
'filter_html_nofollow' => 1,
);
// Test if the rel="nofollow" attribute is added, even if we try to prevent
// it.
$f = _filter_html('<a href="http://www.example.com/">text</a>', $filter);
$this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent -- no evasion.'));
$f = _filter_html('<A href="http://www.example.com/">text</a>', $filter);
$this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- capital A.'));
$f = _filter_html("<a/href=\"http://www.example.com/\">text</a>", $filter);
$this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- non whitespace character after tag name.'));
$f = _filter_html("<\0a\0 href=\"http://www.example.com/\">text</a>", $filter);
$this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- some nulls.'));
$f = _filter_html('<a href="http://www.example.com/" rel="follow">text</a>', $filter);
$this->assertNoNormalized($f, 'rel="follow"', t('Spam deterrent evasion -- with rel set - rel="follow" removed.'));
$this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- with rel set - rel="nofollow" added.'));
}
Login or register to post comments