Browse Source

for debug

stanley-king 4 years ago
parent
commit
f8a907dde9

+ 3 - 3
application/index/controller/Index.php

@@ -5,7 +5,7 @@ namespace app\index\controller;
 class Index
 {
 //    const admin_url = 'host.docker.internal';
-    const admin_url = 'docker.hostip';
+    const admin_url = 'http://docker.hostip:8080';
 
     protected function request($params)
     {
@@ -18,7 +18,7 @@ class Index
     }
     public function CheckOrder(){
         $order_sn = input('param.order_sn');
-        $result = http_get(self::admin_url . ':8080/CheckOrder' ,['order_sn' => $order_sn]);
+        $result = http_get(self::admin_url . '/CheckOrder' ,['order_sn' => $order_sn]);
         if($result == false){
             json_return(500,[],'网络错误');
         }
@@ -26,8 +26,8 @@ class Index
             json_return($result['code'],[],$result['msg']);
         }
         json_success($result['data']);
-
     }
+
     public function CheckFcode(){
         $code = input('param.code');
         $result = http_get(self::admin_url . ':8080/CheckFcode' ,['code' => $code]);

+ 4 - 1
composer.json

@@ -22,7 +22,10 @@
     },
     "autoload": {
         "psr-4": {
-            "app\\": "application"
+            "app\\": "application",
+            "tests\\": "tests",
+            "think\\": "thinkphp/library/think",
+            "traits\\": "thinkphp/library/traits"
         }
     },
     "extra": {

+ 2 - 2
conf/crontab/root

@@ -1,4 +1,4 @@
 # do daily/weekly/monthly maintenance
 # min	hour	day	month	weekday	command
-*/15	*	*	*	*	php /var/www/html/crontab/index.php
-*    *   *   *   *   echo "test" >> /var/test.log
+*/10	*	*	*	*	php /var/www/html/crontab/index.php
+*    *   *   *   *   echo "test" >> /var/test.log- d/phpstudy_pro/WWW/access/conf/etc/localtime:/etc/localtime:ro

+ 43 - 7
crontab/index.php

@@ -1,13 +1,49 @@
 <?php
 
-// [ 应用入口文件 ]
-namespace think;
-
-// 加载基础文件
-
-require __DIR__ . '/../thinkphp/base.php';
-
 define('BASE_ROOT_PATH',str_replace('/crontab','',dirname(__FILE__)));
 define('BASE_PATH',BASE_ROOT_PATH . '/crontab');
+define('BASE_DATA_PATH',BASE_ROOT_PATH . '/data');
+define('APP_ID','crontab');
 
 require_once(BASE_PATH . '/config.ini.php');
+
+require_once(BASE_ROOT_PATH . '/extend/queue.php');
+require_once(BASE_ROOT_PATH . '/extend/queue.logic.php');
+require_once(BASE_ROOT_PATH . '/extend/log.php');
+require_once(BASE_ROOT_PATH . '/extend/http.php');
+
+Log::record("Crontab startHandling something....",Log::DEBUG);
+
+class crontab
+{
+    public function onFifteenMinute()
+    {
+        $cabinets = $this->getAllCabinet();
+        foreach ($cabinets as $cabinet) {
+
+
+        }
+    }
+
+    private function getAllCabinet()
+    {
+
+    }
+
+    private function getBox($cabinet) {
+
+    }
+
+    private function reportState()
+    {
+
+    }
+}
+
+$worker = new crontab();
+$worker->onFifteenMinute();
+
+
+
+
+

+ 1 - 0
tests/ExampleTest.php

@@ -15,6 +15,7 @@ class ExampleTest extends TestCase
 
     public function testBasicExample()
     {
+        $x = 100;
         $this->visit('/')->see('ThinkPHP');
     }
 }

+ 5 - 1
tests/LoginTest.php

@@ -6,6 +6,10 @@ use PHPUnit\Framework\TestCase;
 
 class LoginTest extends TestCase
 {
-
+    public function testBasicExample()
+    {
+        $x = 100;
+        $this->visit('/')->see('ThinkPHP');
+    }
 
 }

+ 9 - 0
tests/TestCase.php

@@ -13,4 +13,13 @@ namespace tests;
 class TestCase extends \think\testing\TestCase
 {
     protected $baseUrl = 'http://localhost';
+
+    public function __construct(?string $name = null, array $data = [], string $dataName = '') {
+        // 引入需要的环境
+        require_once __DIR__ . '/../thinkphp/base.php';
+        // 初始化 App 对象,并将 APP_PATH 指向项目的 application 目录
+        App::getInstance()->path(__DIR__ . '/../application/')->initialize();
+
+        parent::__construct($name, $data, $dataName);
+    }
 }

+ 29 - 0
tests/TestIndex.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace think;
+
+// 加载基础文件
+
+
+define('BASE_ROOT_PATH',str_replace('/tests','',dirname(__FILE__)));
+define('BASE_PATH',BASE_ROOT_PATH . '/tests');
+define('APP_ID','tests');
+
+require BASE_ROOT_PATH . '/thinkphp/base.php';
+
+use PHPUnit\Framework\TestCase;
+
+class TestIndex extends TestCase
+{
+    public static function setUpBeforeClass() : void
+    {
+        App::getInstance()->path(BASE_ROOT_PATH . '/application/')->initialize();
+    }
+    
+    public function testInviteBonus()
+    {
+        $obj = new \app\index\controller\Index;
+        $obj->index();
+    }
+
+}