CrawlerTest::testRemoveExtremityStopWords2()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace rOpenDev\Crawler\Test;
3
4
use rOpenDev\ExtractExpression\CleanText;
5
6
class CrawlerTest extends \PHPUnit\Framework\TestCase
7
{
8
    public function testSimpleSentences()
9
    {
10
        $loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
11
12
        $this->assertSame(4, count(CleanText::getSentences($loremIpsum)));
13
    }
14
15
    public function testRemoveExtremityStopWords()
16
    {
17
        $this->assertSame('ferme', CleanText::removeStopWordsAtExtremity('la ferme'));
18
        $this->assertSame('ferme', CleanText::removeStopWordsAtExtremity('la ferme de'));
19
        $this->assertSame('ferme', CleanText::removeStopWordsAtExtremity('ferme de'));
20
    }
21
22
    public function testRemoveExtremityStopWords2()
23
    {
24
        $this->assertSame('savoir', CleanText::removeStopWordsAtExtremity('savoir plus '));
25
    }
26
27
    public function testremoveStopWords()
28
    {
29
        $this->assertSame('', CleanText::removeStopWords(' http//www '));
30
    }
31
32
    public function testStripTags()
33
    {
34
        $text = '<label class="u-block" for="js-toggler-menu"><svg aria-labelledby="title" role="img" class="u-icon u-icon-burger" viewbox="0 0 18 18" width="18" height="18"><title lang="fr">Icone menu burger</title><span class="u-visually-hidden" aria-hidden="true">Menu</span></label>';
35
36
        $this->assertSame('Icone menu burger Menu', CleanText::stripHtmlTags($text));
37
        $this->assertSame('Icone menu burger Menu', CleanText::stripHtmlTagsOldWay(str_replace('<', ' <', $text)));
38
39
40
        $text = '<label class="u-block" for="js-toggler-menu"><svg aria-labelledby="title" role="img" class="u-icon u-icon-burger" viewbox="0 0 18 18" width="18" height="18"><title lang="fr">Icone menu burger</title>'."\n".'<span class="u-visually-hidden" aria-hidden="true">Menu</span></label>';
41
42
        $this->assertSame('Icone menu burger Menu', CleanText::stripHtmlTags($text));
43
        $this->assertSame('Icone menu burger Menu', CleanText::stripHtmlTagsOldWay(str_replace('<', ' <', $text)));
44
45
    }
46
}
47