50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* PhalApi_App\Common\ArrayUtil_Test
|
|
*
|
|
* 针对 ../src/app/Common/ArrayUtil.php App\Common\ArrayUtil 类的PHPUnit单元测试
|
|
*
|
|
* @author: dogstar 20191231
|
|
*/
|
|
|
|
namespace tests\Base\Common;
|
|
use Base\Common\ArrayUtil;
|
|
|
|
class PhpUnderControl_BaseCommonArrayUtil_Test extends \PHPUnit\Framework\TestCase
|
|
{
|
|
public $appCommonArrayUtil;
|
|
|
|
protected function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->appCommonArrayUtil = new \Base\Common\ArrayUtil();
|
|
}
|
|
|
|
protected function tearDown()
|
|
{
|
|
// 输出本次单元测试所执行的SQL语句
|
|
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
|
|
|
// 输出本次单元测试所涉及的追踪埋点
|
|
// var_dump(\PhalApi\DI()->tracer->getStack());
|
|
}
|
|
|
|
|
|
/**
|
|
* @group testTakeKey
|
|
*/
|
|
public function testTakeKey()
|
|
{
|
|
|
|
$array = array('name' => 'phpunit', 'age' => 1);
|
|
$keys = array('name');
|
|
$rs = $this->appCommonArrayUtil::takeKey($array, $keys);
|
|
$expect = array('name' => 'phpunit');
|
|
$this->assertEquals($rs, $expect);
|
|
|
|
}
|
|
|
|
|
|
}
|