|
1
|
|
|
<?php |
|
2
|
|
|
namespace Rap2hpoutre\RemoveStopWords\Tests; |
|
3
|
|
|
use PHPUnit\Framework\TestCase; |
|
4
|
|
|
use function Rap2hpoutre\RemoveStopWords\remove_stop_words; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class RemoveStopWordsTest |
|
8
|
|
|
* @package Rap2hpoutre\RemoveStopWords\Tests |
|
9
|
|
|
*/ |
|
10
|
|
|
class RemoveStopWordsTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function conversionDataProvider() |
|
13
|
|
|
{ |
|
14
|
|
|
return [ |
|
15
|
|
|
['Hello', 'Hello'], |
|
16
|
|
|
[' quick brown fox jumps lazy dog', 'The quick brown fox jumps over the lazy dog'], |
|
17
|
|
|
[' must explain mistaken idea denouncing pleasure praising pain born give complete account system, expound actual teachings great explorer truth, master-builder human happiness.', 'But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.'], |
|
18
|
|
|
]; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @dataProvider conversionDataProvider |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testConversion($expectedString, $string) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->assertEquals($expectedString, remove_stop_words($string)); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function conversionWithLocaleDataProvider() |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
|
|
[' plaît majesté', 'Ça plaît à sa majesté', 'fr'], |
|
33
|
|
|
['Portez vieux whisky juge blond fume', 'Portez ce vieux whisky au juge blond qui fume', 'fr'], |
|
34
|
|
|
]; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @dataProvider conversionWithLocaleDataProvider |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testConversionWithLocale($expectedString, $string, $locale) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->assertEquals($expectedString, remove_stop_words($string, $locale)); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|