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
|
|
|
|
13
|
|
|
public function testGetChineseFirstChar() |
14
|
|
|
{ |
15
|
|
|
$this->assertEquals('wo', ChineseChar::getChineseFirstChar('我是作者', false, false)); |
16
|
|
|
$this->assertEquals('w', ChineseChar::getChineseFirstChar('我是作者', true, false)); |
17
|
|
|
$this->assertEquals('W', ChineseChar::getChineseFirstChar('我是作者', true, true)); |
18
|
|
|
$this->assertEquals('WO', ChineseChar::getChineseFirstChar('我是作者', false, true)); |
19
|
|
|
$this->assertEquals('A', ChineseChar::getChineseFirstChar('A', false, false)); |
20
|
|
|
$this->assertEquals('h', ChineseChar::getChineseFirstChar('汉字', true, false)); |
21
|
|
|
$this->assertEquals('H', ChineseChar::getChineseFirstChar('汉字', true, true)); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testGetChineseChar() |
25
|
|
|
{ |
26
|
|
|
$this->assertEquals('wo shi zuo zhe', ChineseChar::getChineseChar('我是作者', false, false)); |
27
|
|
|
$this->assertEquals('w s z z', ChineseChar::getChineseChar('我是作者', true, false)); |
28
|
|
|
$this->assertEquals('W S Z Z', ChineseChar::getChineseChar('我是作者', true, true)); |
29
|
|
|
$this->assertEquals('WO SHI ZUO ZHE', ChineseChar::getChineseChar('我是作者', false, true)); |
30
|
|
|
$this->assertEquals('A', ChineseChar::getChineseChar('A', false, false)); |
31
|
|
|
$this->assertEquals('han zi', ChineseChar::getChineseChar('汉字', false, false)); |
32
|
|
|
} |
33
|
|
|
} |