1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of dispositif/wikibot application (@github) |
4
|
|
|
* 2019/2020 © Philippe/Irønie <[email protected]> |
5
|
|
|
* For the full copyright and MIT license information, view the license file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace App\Domain\Utils; |
11
|
|
|
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
|
14
|
|
|
class TextUtilTest extends TestCase |
15
|
|
|
{ |
16
|
1 |
|
public function testBreakingSpace() |
17
|
|
|
{ |
18
|
1 |
|
$html = "bla bla\n"; |
19
|
1 |
|
$text = html_entity_decode($html); |
20
|
1 |
|
$this::assertSame( |
21
|
1 |
|
'bla bla', |
22
|
1 |
|
TextUtil::trim(TextUtil::replaceNonBreakingSpaces($text)) |
23
|
|
|
); |
24
|
1 |
|
} |
25
|
|
|
|
26
|
1 |
|
public function testMb_ucfirst() |
27
|
|
|
{ |
28
|
1 |
|
$this::assertSame( |
29
|
1 |
|
'Économie galante', |
30
|
1 |
|
TextUtil::mb_ucfirst('économie galante') |
31
|
|
|
); |
32
|
1 |
|
} |
33
|
|
|
|
34
|
1 |
|
public function testStripPunctuation() |
35
|
|
|
{ |
36
|
1 |
|
$this::assertSame( |
37
|
1 |
|
'blabla', |
38
|
1 |
|
TextUtil::stripPunctuation('bla¦}©§bla') |
39
|
|
|
); |
40
|
1 |
|
} |
41
|
|
|
|
42
|
1 |
|
public function testStripAccents() |
43
|
|
|
{ |
44
|
1 |
|
$this::assertSame( |
45
|
1 |
|
'Ecealo', |
46
|
1 |
|
TextUtil::stripAccents('Écéàlô') |
47
|
|
|
); |
48
|
1 |
|
} |
49
|
|
|
|
50
|
1 |
|
public function testPredictCorrectParam() |
51
|
|
|
{ |
52
|
1 |
|
$this::assertSame( |
53
|
1 |
|
'auteur', |
54
|
1 |
|
TextUtil::predictCorrectParam('autuer', ['auteur', 'bla', 'hautour']) |
55
|
|
|
); |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
public function testStrEndsWith() |
59
|
|
|
{ |
60
|
|
|
$this::assertSame( |
61
|
|
|
true, |
62
|
|
|
TextUtil::str_ends_with('testaà', 'aà') |
63
|
|
|
); |
64
|
|
|
$this::assertSame( |
65
|
|
|
false, |
66
|
|
|
TextUtil::str_ends_with('testaà', 'test') |
67
|
|
|
); |
68
|
|
|
$this::assertSame( |
69
|
|
|
true, |
70
|
|
|
TextUtil::str_ends_with('testaà', '') |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
public function testStrStqrtsWith() |
74
|
|
|
{ |
75
|
|
|
$this::assertSame( |
76
|
|
|
true, |
77
|
|
|
TextUtil::str_starts_with('téstaà', 'tést') |
78
|
|
|
); |
79
|
|
|
$this::assertSame( |
80
|
|
|
false, |
81
|
|
|
TextUtil::str_starts_with('téstaa', 'aa') |
82
|
|
|
); |
83
|
|
|
$this::assertSame( |
84
|
|
|
true, |
85
|
|
|
TextUtil::str_starts_with('téstaa', '') |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|