function SearchByPageUnitTest::testExcerpt in Search by Page 6
Same name and namespace in other branches
- 7 tests/search_by_page.test \SearchByPageUnitTest::testExcerpt()
Tests the search_by_page_excerpt() function.
File
- tests/
search_by_page.test, line 64 - 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 testExcerpt() {
// Our test class should have made the 'walking' key match walks, walker,
// walking, and walked. They should now be highlighted with <strong> HTML
// tags.
$result = search_by_page_excerpt('walking', 'He walks through the forest');
$this
->assertTrue(strpos($result, '<strong>walks</strong>') > 0, "Excerpt highlights walks");
$result = search_by_page_excerpt('walking', 'He is a walker through the forest');
$this
->assertTrue(strpos($result, '<strong>walker</strong>') > 0, "Excerpt highlights walker");
$result = search_by_page_excerpt('walking', 'He is walking through the forest');
$this
->assertTrue(strpos($result, '<strong>walking</strong>') > 0, "Excerpt highlights walking");
$result = search_by_page_excerpt('walking', 'He walked through the forest');
$this
->assertTrue(strpos($result, '<strong>walked</strong>') > 0, "Excerpt highlights walked");
// Verify that an exact match after a stemmed match highlights the stemmed.
$result = search_by_page_excerpt('walking', 'He walked on the long walk in town');
$this
->assertTrue(strpos($result, '<strong>walked</strong>') > 0, "Excerpt highlights walked");
}