@@ -1,60 +1,60 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once "../core/Logger.php"; |
3 | 3 | class PUnit{ |
4 | - function assertEquals($value,$expected,$info = NULL){ |
|
5 | - if($value != $expected){ |
|
6 | - throw new Exception($info." expected ".$expected." but ".$value); |
|
7 | - } |
|
8 | - } |
|
9 | - function run($torun = NULL){ |
|
10 | - $r = new ReflectionClass($this); |
|
11 | - foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | - if($methodObj->isPrivate()) |
|
13 | - $methods[$key]['type'] = 'private'; |
|
14 | - elseif($methodObj->isProtected()) |
|
15 | - $methods[$key]['type'] = 'protected'; |
|
16 | - else |
|
17 | - $methods[$key]['type'] = 'public'; |
|
18 | - $methods[$key]['name'] = $methodObj->name; |
|
19 | - $methods[$key]['class'] = $methodObj->class; |
|
20 | - } |
|
4 | + function assertEquals($value,$expected,$info = NULL){ |
|
5 | + if($value != $expected){ |
|
6 | + throw new Exception($info." expected ".$expected." but ".$value); |
|
7 | + } |
|
8 | + } |
|
9 | + function run($torun = NULL){ |
|
10 | + $r = new ReflectionClass($this); |
|
11 | + foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | + if($methodObj->isPrivate()) |
|
13 | + $methods[$key]['type'] = 'private'; |
|
14 | + elseif($methodObj->isProtected()) |
|
15 | + $methods[$key]['type'] = 'protected'; |
|
16 | + else |
|
17 | + $methods[$key]['type'] = 'public'; |
|
18 | + $methods[$key]['name'] = $methodObj->name; |
|
19 | + $methods[$key]['class'] = $methodObj->class; |
|
20 | + } |
|
21 | 21 | $before = NULL; |
22 | 22 | $after = NULL; |
23 | 23 | foreach ($methods as $method) { |
24 | - if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
24 | + if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
25 | 25 | $before = $method; |
26 | - } |
|
27 | - if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
26 | + } |
|
27 | + if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
28 | 28 | $after = $method; |
29 | - } |
|
29 | + } |
|
30 | 30 | } |
31 | - $error = array(); |
|
32 | - $success = array(); |
|
33 | - foreach ($methods as $method) { |
|
34 | - if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
31 | + $error = array(); |
|
32 | + $success = array(); |
|
33 | + foreach ($methods as $method) { |
|
34 | + if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
35 | 35 | if($torun !== NULL){ |
36 | - if(!in_array($method["name"],$torun)) |
|
36 | + if(!in_array($method["name"],$torun)) |
|
37 | 37 | continue; |
38 | 38 | } |
39 | - try{ |
|
40 | - if($method["type"] == "public"){ |
|
39 | + try{ |
|
40 | + if($method["type"] == "public"){ |
|
41 | 41 | $log = new Logger(); |
42 | 42 | $log->info("Run unit --->".$method["name"]); |
43 | 43 | if($before!=NULL) |
44 | - $this->$before["name"](); |
|
45 | - $this->$method["name"](); |
|
46 | - array_push($success,$method["name"]); |
|
47 | - } |
|
48 | - }catch(Exception $e){ |
|
49 | - $error[$method["name"]]="".$e; |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
53 | - echo "\r\nPHP Unit-----------error"."\r\n"; |
|
54 | - print_r($error); |
|
44 | + $this->$before["name"](); |
|
45 | + $this->$method["name"](); |
|
46 | + array_push($success,$method["name"]); |
|
47 | + } |
|
48 | + }catch(Exception $e){ |
|
49 | + $error[$method["name"]]="".$e; |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | + echo "\r\nPHP Unit-----------error"."\r\n"; |
|
54 | + print_r($error); |
|
55 | 55 | echo "PHP Unit-----------result"."\r\n"; |
56 | 56 | echo "total:".(count($success)+count($error)).",success:".count($success).",error:".count($error)."\r\n"; |
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | ?> |
61 | 61 | \ No newline at end of file |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once "../core/Logger.php"; |
3 | -class PUnit{ |
|
4 | - function assertEquals($value,$expected,$info = NULL){ |
|
5 | - if($value != $expected){ |
|
3 | +class PUnit { |
|
4 | + function assertEquals($value, $expected, $info = NULL) { |
|
5 | + if ($value != $expected) { |
|
6 | 6 | throw new Exception($info." expected ".$expected." but ".$value); |
7 | 7 | } |
8 | 8 | } |
9 | - function run($torun = NULL){ |
|
9 | + function run($torun = NULL) { |
|
10 | 10 | $r = new ReflectionClass($this); |
11 | - foreach($r->getMethods() as $key=>$methodObj){ |
|
12 | - if($methodObj->isPrivate()) |
|
11 | + foreach ($r->getMethods() as $key=>$methodObj) { |
|
12 | + if ($methodObj->isPrivate()) |
|
13 | 13 | $methods[$key]['type'] = 'private'; |
14 | - elseif($methodObj->isProtected()) |
|
14 | + elseif ($methodObj->isProtected()) |
|
15 | 15 | $methods[$key]['type'] = 'protected'; |
16 | 16 | else |
17 | 17 | $methods[$key]['type'] = 'public'; |
@@ -21,32 +21,32 @@ discard block |
||
21 | 21 | $before = NULL; |
22 | 22 | $after = NULL; |
23 | 23 | foreach ($methods as $method) { |
24 | - if($method["class"] != "PUnit"&&$method["name"] == "before"){ |
|
24 | + if ($method["class"] != "PUnit" && $method["name"] == "before") { |
|
25 | 25 | $before = $method; |
26 | 26 | } |
27 | - if($method["class"] != "PUnit"&&$method["name"] == "after"){ |
|
27 | + if ($method["class"] != "PUnit" && $method["name"] == "after") { |
|
28 | 28 | $after = $method; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | $error = array(); |
32 | 32 | $success = array(); |
33 | 33 | foreach ($methods as $method) { |
34 | - if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
|
35 | - if($torun !== NULL){ |
|
36 | - if(!in_array($method["name"],$torun)) |
|
34 | + if ($method["class"] != "PUnit" && substr($method["name"], 0, 4) == "test") { |
|
35 | + if ($torun !== NULL) { |
|
36 | + if (!in_array($method["name"], $torun)) |
|
37 | 37 | continue; |
38 | 38 | } |
39 | - try{ |
|
40 | - if($method["type"] == "public"){ |
|
39 | + try { |
|
40 | + if ($method["type"] == "public") { |
|
41 | 41 | $log = new Logger(); |
42 | 42 | $log->info("Run unit --->".$method["name"]); |
43 | - if($before!=NULL) |
|
43 | + if ($before != NULL) |
|
44 | 44 | $this->$before["name"](); |
45 | 45 | $this->$method["name"](); |
46 | - array_push($success,$method["name"]); |
|
46 | + array_push($success, $method["name"]); |
|
47 | 47 | } |
48 | - }catch(Exception $e){ |
|
49 | - $error[$method["name"]]="".$e; |
|
48 | + } catch (Exception $e) { |
|
49 | + $error[$method["name"]] = "".$e; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
@@ -9,12 +9,13 @@ discard block |
||
9 | 9 | function run($torun = NULL){ |
10 | 10 | $r = new ReflectionClass($this); |
11 | 11 | foreach($r->getMethods() as $key=>$methodObj){ |
12 | - if($methodObj->isPrivate()) |
|
13 | - $methods[$key]['type'] = 'private'; |
|
14 | - elseif($methodObj->isProtected()) |
|
15 | - $methods[$key]['type'] = 'protected'; |
|
16 | - else |
|
17 | - $methods[$key]['type'] = 'public'; |
|
12 | + if($methodObj->isPrivate()) { |
|
13 | + $methods[$key]['type'] = 'private'; |
|
14 | + } elseif($methodObj->isProtected()) { |
|
15 | + $methods[$key]['type'] = 'protected'; |
|
16 | + } else { |
|
17 | + $methods[$key]['type'] = 'public'; |
|
18 | + } |
|
18 | 19 | $methods[$key]['name'] = $methodObj->name; |
19 | 20 | $methods[$key]['class'] = $methodObj->class; |
20 | 21 | } |
@@ -33,19 +34,21 @@ discard block |
||
33 | 34 | foreach ($methods as $method) { |
34 | 35 | if($method["class"] != "PUnit"&&substr($method["name"],0,4) == "test"){ |
35 | 36 | if($torun !== NULL){ |
36 | - if(!in_array($method["name"],$torun)) |
|
37 | - continue; |
|
37 | + if(!in_array($method["name"],$torun)) { |
|
38 | + continue; |
|
39 | + } |
|
38 | 40 | } |
39 | 41 | try{ |
40 | 42 | if($method["type"] == "public"){ |
41 | 43 | $log = new Logger(); |
42 | 44 | $log->info("Run unit --->".$method["name"]); |
43 | - if($before!=NULL) |
|
44 | - $this->$before["name"](); |
|
45 | + if($before!=NULL) { |
|
46 | + $this->$before["name"](); |
|
47 | + } |
|
45 | 48 | $this->$method["name"](); |
46 | 49 | array_push($success,$method["name"]); |
47 | 50 | } |
48 | - }catch(Exception $e){ |
|
51 | + } catch(Exception $e){ |
|
49 | 52 | $error[$method["name"]]="".$e; |
50 | 53 | } |
51 | 54 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (empty($this->accessKeyID) || empty($this->accessKeySecret) || empty($this->endpoint)) { |
82 | 82 | $this->getConfig(); |
83 | 83 | } |
84 | - require_once(__DIR__ . "/bin/Ks3Client.class.php"); |
|
84 | + require_once(__DIR__."/bin/Ks3Client.class.php"); |
|
85 | 85 | $client = new Ks3Client($this->accessKeyID, $this->accessKeySecret, $this->endpoint); |
86 | 86 | if (empty($this->bucket)) { |
87 | 87 | $this->getConfig(); |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | "Key" => $object, |
93 | 93 | "Content" => [ |
94 | 94 | //要上传的内容 |
95 | - "content" => $content,//可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
95 | + "content" => $content, //可以是文件路径或者resource,如果文件大于2G,请提供文件路径 |
|
96 | 96 | "seek_position" => 0//跳过文件开头?个字节 |
97 | 97 | ], |
98 | - "ACL" => "public-read",//可以设置访问权限,合法值,private、public-read |
|
98 | + "ACL" => "public-read", //可以设置访问权限,合法值,private、public-read |
|
99 | 99 | "ObjectMeta" => [ |
100 | 100 | //设置object的元数据,可以设置"Cache-Control","Content-Disposition","Content-Encoding","Content-Length","Content-MD5","Content-Type","Expires"。当设置了Content-Length时,最后上传的为从seek_position开始向后Content-Length个字节的内容。当设置了Content-MD5时,系统会在服务端进行md5校验。 |
101 | 101 | "Content-Type" => "binay/ocet-stream" |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ]; |
109 | 109 | try { |
110 | 110 | $client->putObjectByFile($args); |
111 | - return config('dtapp.ksyun.ks3.url', '') . $object; |
|
111 | + return config('dtapp.ksyun.ks3.url', '').$object; |
|
112 | 112 | } catch (Ks3ServiceException $e) { |
113 | 113 | return false; |
114 | 114 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | $data['msgtype'] = $this->msg_type; |
84 | 84 | } |
85 | 85 | $result = HttpService::instance() |
86 | - ->url("{$this->oapi_url}robot/send?access_token=" . $this->access_token) |
|
86 | + ->url("{$this->oapi_url}robot/send?access_token=".$this->access_token) |
|
87 | 87 | ->data($data) |
88 | 88 | ->post() |
89 | 89 | ->toArray(); |
@@ -80,6 +80,6 @@ |
||
80 | 80 | $client = new Upyun($serviceConfig); |
81 | 81 | $file = fopen($filePath, 'r'); |
82 | 82 | $client->write($object, $file); |
83 | - return config('dtapp.upyun.uss.url', '') . $object; |
|
83 | + return config('dtapp.upyun.uss.url', '').$object; |
|
84 | 84 | } |
85 | 85 | } |
@@ -96,6 +96,6 @@ |
||
96 | 96 | $this->getConfig(); |
97 | 97 | } |
98 | 98 | $client->putObjectFromFile($this->bucket, $object, $filePath); |
99 | - return config('dtapp.baidu.bos.url', '') . $object; |
|
99 | + return config('dtapp.baidu.bos.url', '').$object; |
|
100 | 100 | } |
101 | 101 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $result = Db::table($this->table) |
136 | 136 | ->where('cache_name', $this->cache_name) |
137 | 137 | ->update([ |
138 | - 'cache_value' => $cache_value + $int |
|
138 | + 'cache_value' => $cache_value+$int |
|
139 | 139 | ]); |
140 | 140 | return $result ? true : false; |
141 | 141 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $result = Db::table($this->table) |
154 | 154 | ->where('cache_name', $this->cache_name) |
155 | 155 | ->update([ |
156 | - 'cache_value' => $cache_value - $int |
|
156 | + 'cache_value' => $cache_value-$int |
|
157 | 157 | ]); |
158 | 158 | return $result ? true : false; |
159 | 159 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
18 | 18 | // +---------------------------------------------------------------------- |
19 | 19 | |
20 | -declare (strict_types=1); |
|
20 | +declare(strict_types=1); |
|
21 | 21 | |
22 | 22 | namespace DtApp\ThinkLibrary\helper; |
23 | 23 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
18 | 18 | // +---------------------------------------------------------------------- |
19 | 19 | |
20 | -declare (strict_types=1); |
|
20 | +declare(strict_types=1); |
|
21 | 21 | |
22 | 22 | namespace DtApp\ThinkLibrary\helper; |
23 | 23 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library |
18 | 18 | // +---------------------------------------------------------------------- |
19 | 19 | |
20 | -declare (strict_types=1); |
|
20 | +declare(strict_types=1); |
|
21 | 21 | |
22 | 22 | namespace DtApp\ThinkLibrary\facade; |
23 | 23 |