summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt7
-rw-r--r--porterstemmer.test102
2 files changed, 107 insertions, 2 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 8c70b27..4fedd30 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -7,6 +7,13 @@ Porter Stemmer 6.x-2.x, xxxx-xx-xx
----------------------------------
+Porter Stemmer 6.x-2.5, xxxx-xx-xx
+----------------------------------
+#651850 by Archnemysis: Remove by-reference argument in hook_search_preprocess.
+
+#651850 by jhodgdon: Add functional test for module.
+
+
Porter Stemmer 6.x-2.4, 2009-11-19
----------------------------------
#610716 by jhodgdon, alex_b: Use the PECL stemming library if available.
diff --git a/porterstemmer.test b/porterstemmer.test
index e45c733..4b98bdc 100644
--- a/porterstemmer.test
+++ b/porterstemmer.test
@@ -5,12 +5,111 @@
* @file
* Tests for the Porter Stemmer module.
* By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
- * Based on sample words from
+ * Unit tests are based on sample words from
* http://snowball.tartarus.org/algorithms/english/stemmer.html
* which are stored in a separate file (testwords.txt).
*/
/**
+ * Functional test for Porter Stemmer.
+ */
+class PorterStemmerFunctionalTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => t('Functional test'),
+ 'description' => t('Test that stemmed searching works.'),
+ 'group' => t('Porter Stemmer'),
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('porterstemmer', 'search');
+
+ // Set up a super-user
+ $this->superuser = $this->drupalCreateUser( array( 'administer nodes',
+ 'access content', 'administer content types',
+ 'administer search', 'search content',
+ 'access administration pages',
+ 'administer site configuration' ));
+ $this->drupalLogin( $this->superuser );
+
+ // Create some content to search, with the words walk, walking, and walked.
+ $info = array(
+ 'body' => 'I walk through the streets, looking around for trouble',
+ 'type' => 'page',
+ 'title' => 'first page',
+ );
+ $node = $this->drupalCreateNode($info);
+
+ $info = array(
+ 'body' => 'I walked home from work today.',
+ 'type' => 'page',
+ 'title' => 'second page',
+ );
+ $node = $this->drupalCreateNode($info);
+
+ $info = array(
+ 'body' => 'I am always walking everywhere.',
+ 'type' => 'page',
+ 'title' => 'third page',
+ );
+ $node = $this->drupalCreateNode($info);
+
+ // Run cron to ensure this content is indexed
+ // Note: Could use $this->cronRun(), but not available in 6.x SimpleTest,
+ // so using the body of cronRun() from Drupal 7 instead
+ $this->drupalGet($GLOBALS['base_url'] . '/cron.php',
+ array(
+ 'external' => TRUE,
+ 'query' => array('cron_key' => variable_get('cron_key', 'drupal'))
+ ));
+ }
+
+ /**
+ * Tests that all three pages can be found in searches.
+ */
+ function testSearch() {
+ $this->drupalLogin( $this->superuser );
+
+ // Search for 'walk' and verify all three pages were found.
+ $this->drupalPost('search',
+ array('keys' => 'walk' ),
+ 'Search'
+ );
+ $this->assertText('first', 'First page was found with search for walk');
+ $this->assertText('second', 'Second page was found with search for walk');
+ $this->assertText('third', 'Third page was found with search for walk');
+
+ // Search for 'walking' and verify all three pages were found.
+ $this->drupalPost('search',
+ array('keys' => 'walking' ),
+ 'Search'
+ );
+ $this->assertText('first', 'First page was found with search for walking');
+ $this->assertText('second', 'Second page was found with search for walking');
+ $this->assertText('third', 'Third page was found with search for walking');
+
+ // Search for 'walked' and verify all three pages were found.
+ $this->drupalPost('search',
+ array('keys' => 'walked' ),
+ 'Search'
+ );
+ $this->assertText('first', 'First page was found with search for walked');
+ $this->assertText('second', 'Second page was found with search for walked');
+ $this->assertText('third', 'Third page was found with search for walked');
+
+ // Search for 'blahblahblah' and verify none of the pages were found.
+ $this->drupalPost('search',
+ array('keys' => 'blahblahblah' ),
+ 'Search'
+ );
+ $this->assertNoText('first', 'First page was not found with bogus search');
+ $this->assertNoText('second', 'Second page was not found with bogus search');
+ $this->assertNoText('third', 'Third page was not found with bogus search');
+ }
+}
+
+/**
* Unit tests for Porter Stemmer - Stemming output part 1.
*/
class PorterStemmerOutput1UnitTest extends DrupalWebTestCase {
@@ -931,7 +1030,6 @@ class PorterStemmerPECLOutput14UnitTest extends PorterStemmerOutput1UnitTest {
}
}
-///////////////////////////////////////
/**
* Unit tests for Porter Stemmer - Stemming output part 15 PECL.
*/