Completed
Pull Request — master (#3)
by lee
01:20
created

RemoveStopWordsTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 4
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A conversionDataProvider() 0 8 1
A testConversion() 0 4 1
A conversionWithLocaleDataProvider() 0 7 1
A testConversionWithLocale() 0 4 1
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