123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace think;
- // 加载基础文件
- define('BASE_ROOT_PATH',str_replace('/tests','',dirname(__FILE__)));
- define('BASE_PATH',BASE_ROOT_PATH . '/tests');
- define('APP_ID','tests');
- define('BASE_DATA_PATH',BASE_ROOT_PATH . '/data');
- require_once(BASE_ROOT_PATH . '/other/config.ini.php');
- require_once(BASE_ROOT_PATH . '/thinkphp/base.php');
- require_once(BASE_ROOT_PATH . '/extend/http.php');
- require_once(BASE_ROOT_PATH . '/extend/queue.logic.php');
- require_once(BASE_ROOT_PATH . '/extend/log.php');
- use PHPUnit\Framework\TestCase;
- use queue_logic;
- class TestIndex extends TestCase
- {
- protected $baseUrl = 'http://localhost';
- public static function setUpBeforeClass() : void
- {
- App::getInstance()->path(BASE_ROOT_PATH . '/application/')->initialize();
- }
- public function testCheckOrder()
- {
- $resp = http_request('http://host.docker.internal:8080/CheckOrder',['order_sn' => '123456'],'GET');
- }
- public function testInviteBonus()
- {
- $obj = new \app\index\controller\Index;
- $obj->_CheckOrder('123456789');
- }
- public function testOpenBox()
- {
- $logic_queue = new queue_logic();
- $logic_queue->OpenBox(['cabinet_code' => '0000000000000000','box_position_list' => [1],'delay_time' => 0,
- 'req_url' => 'http://221.217.229.194:8888','key' => '12345678','id' => '1234567' ,'ret_queue' => 'test_queue']);
- }
- public function testLockCabinet()
- {
- $logic_queue = new queue_logic();
- $logic_queue->OpenBox(['cabinet_code' => '0000000000000000','delay_time' => 0,
- 'req_url' => 'http://221.217.229.194:8888','key' => '12345678','id' => '1234567' ,'ret_queue' => 'test_queue']);
- }
- public function testQueryBoxState()
- {
- $logic_queue = new queue_logic();
- $logic_queue->QueryBoxState(['cabinet_code' => '0000000000000000','box_position_list' => [1],'delay_time' => 0,
- 'req_url' => 'http://221.217.229.194:8888','key' => '12345678','id' => '1234567','ret_queue' => 'test_queue']);
- }
- public function testUpdateAllBoxState()
- {
- $logic_queue = new queue_logic();
- $logic_queue->UpdateAllBoxState();
- }
- private function eliTime($seconds){
- if($seconds >= 86400){
- $day = floor($seconds / 86400);
- $remain = $seconds % 86400;
- }
- if($remain >= 3600){
- $hour = floor($remain / 3600);
- $remain = $remain % 3600;
- }
- if($remain >= 60){
- $minute = floor($remain / 60);
- }
- $second = $remain % 60;
- if($day == 0){
- return "{$hour}小时{$minute}分钟{$second}秒";
- }else{
- return "{$day}天{$hour}小时{$minute}分钟{$second}秒";
- }
- }
- public function testTime()
- {
- $x = 142596;
- $text = $this->eliTime($x);
- }
- }
|