function SearchByPageUnitTest::testStripTags in Search by Page 6
Same name and namespace in other branches
- 7 tests/search_by_page.test \SearchByPageUnitTest::testStripTags()
Tests the search_by_page_strip_tags function.
File
- tests/
search_by_page.test, line 89 - Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageUnitTest
- Unit tests for Search by Page functions.
Code
function testStripTags() {
$env = 1;
$test_string = '<div>This is a test. <tag1>This should be removed</tag1> <tag2>This should also be removed</tag2> This should be left. <tag1>This should not be here</tag1><tag1 some="attribute">This although with attributes, should also be removed</tag1></div>';
// Try excluding some tags.
search_by_page_setting_set('exclude_tags', $env, 'tag1 tag2');
$result = search_by_page_strip_tags($test_string, $env);
$this
->assertEqual($result, '<div>This is a test. This should be left. </div>', 'search_by_page_strip_tags() is working correctly.');
// Try not excluding any tags.
search_by_page_setting_set('exclude_tags', $env, '');
$result = search_by_page_strip_tags($test_string, $env);
$this
->assertEqual($result, $test_string, 'search_by_page_strip_tags() with no tags to strip is working correctly.');
}