Passed
Push — master ( b0f0bc...e7fcd7 )
by ma
02:00
created

ChineseCharTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 2 1
A testName() 0 3 1
A testGetChineseChar() 0 8 1
A testGetChineseFirstChar() 0 9 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use tinymeng\tools\ChineseChar;
5
6
class ChineseCharTest extends TestCase
7
{
8
    protected function setUp(): void
9
    {
10
        // 这里可以进行一些初始化操作
11
    }
12
    public function testName()
13
    {
14
        var_dump(ChineseChar::getChineseChar('葛鿉会', false, false));
0 ignored issues
show
Security Debugging Code introduced by
var_dump(tinymeng\tools\...鿉会', false, false)) looks like debug code. Are you sure you do not want to remove it?
Loading history...
15
    }
16
17
    public function testGetChineseFirstChar()
18
    {
19
        $this->assertEquals('wo', ChineseChar::getChineseFirstChar('我是作者', false, false));
20
        $this->assertEquals('w', ChineseChar::getChineseFirstChar('我是作者', true, false));
21
        $this->assertEquals('W', ChineseChar::getChineseFirstChar('我是作者', true, true));
22
        $this->assertEquals('WO', ChineseChar::getChineseFirstChar('我是作者', false, true));
23
        $this->assertEquals('A', ChineseChar::getChineseFirstChar('A', false, false));
24
        $this->assertEquals('h', ChineseChar::getChineseFirstChar('汉字', true, false));
25
        $this->assertEquals('H', ChineseChar::getChineseFirstChar('汉字', true, true));
26
    }
27
28
    public function testGetChineseChar()
29
    {
30
        $this->assertEquals('wo shi zuo zhe', ChineseChar::getChineseChar('我是作者', false, false));
31
        $this->assertEquals('w s z z', ChineseChar::getChineseChar('我是作者', true, false));
32
        $this->assertEquals('W S Z Z', ChineseChar::getChineseChar('我是作者', true, true));
33
        $this->assertEquals('WO SHI ZUO ZHE', ChineseChar::getChineseChar('我是作者', false, true));
34
        $this->assertEquals('A', ChineseChar::getChineseChar('A', false, false));
35
        $this->assertEquals('han zi', ChineseChar::getChineseChar('汉字', false, false));
36
    }
37
}