3.8.1
This commit is contained in:
112
tests/admin/Api/Pinyin_Test.php
Normal file
112
tests/admin/Api/Pinyin_Test.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* PhalApi_App\Api\Pinyin_Test
|
||||
*
|
||||
* 针对 ./src/app/Api/Pinyin.php App\Api\Pinyin 类的PHPUnit单元测试
|
||||
*
|
||||
* @author: dogstar 20200107
|
||||
*/
|
||||
|
||||
namespace tests\Admin\Api;
|
||||
use Admin\Api\Pinyin;
|
||||
use PhalApi\Helper\TestRunner;
|
||||
|
||||
class PhpUnderControl_AppApiPinyin_Test extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public $appApiPinyin;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->appApiPinyin = new \Admin\Api\Pinyin();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
// 输出本次单元测试所执行的SQL语句
|
||||
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
||||
|
||||
// 输出本次单元测试所涉及的追踪埋点
|
||||
// var_dump(\PhalApi\DI()->tracer->getStack());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group testGetRules
|
||||
*/
|
||||
public function testGetRules()
|
||||
{
|
||||
$rs = $this->appApiPinyin->getRules();
|
||||
$this->assertTrue(is_array($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testConvert
|
||||
*/
|
||||
public function testConvert()
|
||||
{
|
||||
//Step 1. 构建请求URL
|
||||
$url = 'service=Admin.Pinyin.Convert&text=你好';
|
||||
|
||||
//Step 2. 执行请求
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
//Step 3. 验证
|
||||
$this->assertNotEmpty($rs);
|
||||
$this->assertNotEmpty($rs['pinyin']);
|
||||
$this->assertEquals($rs['pinyin'], "ni hao");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testAbbr
|
||||
*/
|
||||
public function testAbbr()
|
||||
{
|
||||
//Step 1. 构建请求URL
|
||||
$url = 'service=Admin.Pinyin.Abbr&text=你好';
|
||||
|
||||
//Step 2. 执行请求
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
//Step 3. 验证
|
||||
$this->assertNotEmpty($rs);
|
||||
$this->assertNotEmpty($rs['pinyin']);
|
||||
$this->assertEquals($rs['pinyin'], "n h");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testSentence
|
||||
*/
|
||||
public function testSentence()
|
||||
{
|
||||
//Step 1. 构建请求URL
|
||||
$url = 'service=Admin.Pinyin.Sentence&text=你好!';
|
||||
|
||||
//Step 2. 执行请求
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
//Step 3. 验证
|
||||
$this->assertNotEmpty($rs);
|
||||
$this->assertNotEmpty($rs['pinyin']);
|
||||
$this->assertEquals($rs['pinyin'], "ni hao!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testName
|
||||
*/
|
||||
public function testName()
|
||||
{
|
||||
//Step 1. 构建请求URL
|
||||
$url = 'service=Admin.Pinyin.Name&text=单田芳!';
|
||||
|
||||
//Step 2. 执行请求
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
//Step 3. 验证
|
||||
$this->assertNotEmpty($rs);
|
||||
$this->assertNotEmpty($rs['pinyin']);
|
||||
$this->assertEquals($rs['pinyin'], "shan tian fang");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user