81 lines
1.8 KiB
PHP
81 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* PhalApi_Admin\Api\File_Test
|
|
*
|
|
* 针对 ./src/admin/Api/File.php Admin\Api\File 类的PHPUnit单元测试
|
|
*
|
|
* @author: dogstar 20200113
|
|
*/
|
|
|
|
namespace tests\Admin\Api;
|
|
use Admin\Api\File;
|
|
use PhalApi\Helper\TestRunner;
|
|
|
|
class PhpUnderControl_AdminApiFile_Test extends \PHPUnit\Framework\TestCase
|
|
{
|
|
public $adminApiFile;
|
|
|
|
protected function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->adminApiFile = new \Admin\Api\File();
|
|
}
|
|
|
|
protected function tearDown()
|
|
{
|
|
// 输出本次单元测试所执行的SQL语句
|
|
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
|
|
|
// 输出本次单元测试所涉及的追踪埋点
|
|
// var_dump(\PhalApi\DI()->tracer->getStack());
|
|
}
|
|
|
|
|
|
/**
|
|
* @group testGetRules
|
|
*/
|
|
public function testGetRules()
|
|
{
|
|
$rs = $this->adminApiFile->getRules();
|
|
}
|
|
|
|
/**
|
|
* @group testGetList
|
|
*/
|
|
public function testGetList()
|
|
{
|
|
// 提供一些数据
|
|
$domain = new \Base\Domain\File();
|
|
$domain->addUploadFile('x.jpg', 'jpg', 10, '/uploads/haha.png', 'http://localhost/uploads/haha.png');
|
|
|
|
$url = "service=Admin.File.GetList";
|
|
$rs = TestRunner::go($url);
|
|
|
|
$this->assertNotEmpty($rs);
|
|
|
|
$this->assertNotEmpty($rs['total']);
|
|
$this->assertNotEmpty($rs['files']);
|
|
}
|
|
|
|
/**
|
|
* @group testDelFile
|
|
*/
|
|
public function testDelFile()
|
|
{
|
|
// 提供一些数据
|
|
$domain = new \Base\Domain\File();
|
|
$id = $domain->addUploadFile('x.jpg', 'jpg', 10, '/uploads/haha.png', 'http://localhost/uploads/haha.png');
|
|
|
|
$url = "service=Admin.File.DelFile&id=$id";
|
|
|
|
$rs = TestRunner::go($url);
|
|
|
|
$this->assertTrue(is_bool($rs));
|
|
|
|
$this->assertTrue($rs);
|
|
|
|
}
|
|
|
|
}
|