Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / web / modules / contrib / porterstemmer / tests / src / Unit / Porter2Pecl3.php
diff --git a/web/modules/contrib/porterstemmer/tests/src/Unit/Porter2Pecl3.php b/web/modules/contrib/porterstemmer/tests/src/Unit/Porter2Pecl3.php
new file mode 100644 (file)
index 0000000..1a54127
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+namespace Drupal\Tests\porterstemmer\Unit;
+
+/**
+ * Tests the "PorterStemmer" implementation with PECL stem_english().
+ *
+ * @group porterstemmer
+ *
+ * @see https://pecl.php.net/package/stem
+ */
+class Porter2Pecl3 extends PorterPeclBase {
+
+  /**
+   * Test PECL stem_english() with a data provider method.
+   *
+   * Uses the data provider method to test with a wide range of words/stems.
+   *
+   * @dataProvider stemDataProvider
+   */
+  public function testStem($word, $stem) {
+    if ($this->has_pecl_stem) {
+      $this->assertEquals($stem, stem_english($word));
+    }
+    else {
+      $this->assertTrue(TRUE, 'No PECL stem library found, Aborting test.');
+    }
+  }
+
+  /**
+   * Data provider for testStem().
+   *
+   * @return array
+   *   Nested arrays of values to check:
+   *   - $word
+   *   - $stem
+   */
+  public function stemDataProvider() {
+    if ($this->has_pecl_stem) {
+      return $this->retrieveStemWords(10000);
+    }
+    else {
+      return array(array('', ''));
+    }
+  }
+
+}