Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / web / modules / contrib / porterstemmer / tests / src / Unit / Porter2Test2.php
diff --git a/web/modules/contrib/porterstemmer/tests/src/Unit/Porter2Test2.php b/web/modules/contrib/porterstemmer/tests/src/Unit/Porter2Test2.php
new file mode 100644 (file)
index 0000000..6849446
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace Drupal\Tests\porterstemmer\Unit;
+
+use Drupal\Tests\UnitTestCase;
+use Drupal\porterstemmer\Porter2;
+
+/**
+ * Tests the "PorterStemmer" implementation.
+ *
+ * @coversDefaultClass \Drupal\porterstemmer\Porter2
+ * @group porterstemmer
+ *
+ * @see \Drupal\porterstemmer\Porter2
+ */
+class Porter2Test2 extends UnitTestCase {
+
+  use TestItemsTrait;
+
+  /**
+   * Test Porter2::stem() 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) {
+    $this->assertEquals($stem, Porter2::stem($word));
+  }
+
+  /**
+   * Data provider for testStem().
+   *
+   * @return array
+   *   Nested arrays of values to check:
+   *   - $word
+   *   - $stem
+   */
+  public function stemDataProvider() {
+    return $this->retrieveStemWords(5000, 5000);
+  }
+
+}