Added the Porter Stemmer module to improve searches. This doesn't deal with some...
[yaffs-website] / web / modules / contrib / porterstemmer / tests / src / Unit / Porter2Pecl5.php
1 <?php
2
3 namespace Drupal\Tests\porterstemmer\Unit;
4
5 /**
6  * Tests the "PorterStemmer" implementation with PECL stem_english().
7  *
8  * @group porterstemmer
9  *
10  * @see https://pecl.php.net/package/stem
11  */
12 class Porter2Pecl5 extends PorterPeclBase {
13
14   /**
15    * Test PECL stem_english() with a data provider method.
16    *
17    * Uses the data provider method to test with a wide range of words/stems.
18    *
19    * @dataProvider stemDataProvider
20    */
21   public function testStem($word, $stem) {
22     if ($this->has_pecl_stem) {
23       $this->assertEquals($stem, stem_english($word));
24     }
25     else {
26       $this->assertTrue(TRUE, 'No PECL stem library found, Aborting test.');
27     }
28   }
29
30   /**
31    * Data provider for testStem().
32    *
33    * @return array
34    *   Nested arrays of values to check:
35    *   - $word
36    *   - $stem
37    */
38   public function stemDataProvider() {
39     if ($this->has_pecl_stem) {
40       return $this->retrieveStemWords(20000);
41     }
42     else {
43       return array(array('', ''));
44     }
45   }
46
47 }