-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseMapTest.php
80 lines (71 loc) · 1.96 KB
/
CaseMapTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
use PHPUnit\Framework\TestCase;
use jpuck\mbstring\CaseMap;
class CaseMapTest extends TestCase
{
public function test_can_instantiate_object()
{
$this->assertInstanceOf(CaseMap::class, new CaseMap);
}
public function test_can_initialize_object()
{
$this->assertInstanceOf(CaseMap::class, new CaseMap('тоҷик'));
}
public function charCaseDataProvider()
{
return [
['A', true ],
['a', false],
['Ғ', true ],
['ғ', false],
['Г', true ],
['г', false],
['Ӣ', true ],
['ӣ', false],
['И', true ],
['и', false],
['Ҷ', true ],
['ҷ', false],
['Ч', true ],
['ч', false],
['Ҳ', true ],
['ҳ', false],
['Х', true ],
['х', false],
['Қ', true ],
['қ', false],
['К', true ],
['к', false],
['Ӯ', true ],
['ӯ', false],
['У', true ],
['у', false],
['Т', true ],
['т', false],
[' ', false],
['1', false],
];
}
/**
* @dataProvider charCaseDataProvider
*/
public function test_can_determine_case(string $char, bool $capitalized)
{
$this->assertSame($capitalized, (new CaseMap)->isUpper($char));
}
/**
* @expectedException InvalidArgumentException
*/
public function test_can_invalidate_too_many_chars()
{
(new CaseMap)->isUpper('AB');
}
public function test_can_transform_string_by_case_map()
{
$sample = 'This is A MiXeD CasE STRING';
$string = 'abҲd FGH jklқnopqRstuvwxyz0123 Тfӯ';
$expect = 'Abҳd fgh jKlҚnOpQrsTuVWXYZ0123 Тfӯ';
$actual = (new CaseMap($sample))->transform($string);
$this->assertSame($expect, $actual);
}
}