Browse Source

修复测试用例

Signed-off-by: Gorden Freeman <endoffight@gmail.com>
Gorden Freeman 6 years ago
parent
commit
14f9da9caf
1 changed files with 10 additions and 8 deletions
  1. 10 8
      test/TestTaobaoApi.php

+ 10 - 8
test/TestTaobaoApi.php

@@ -22,31 +22,33 @@ class TestTaobaoApi extends PHPUnit_Framework_TestCase
 
 
     public function testApi()
     public function testApi()
     {
     {
-
         $jsonData = '{"mobile":"15038530312"}';
         $jsonData = '{"mobile":"15038530312"}';
         $appkey = "90158432354";
         $appkey = "90158432354";
         $appSecurity = "620054871918";
         $appSecurity = "620054871918";
         $method = 'business.request.MixMobileRequest';
         $method = 'business.request.MixMobileRequest';
-        $post_data = [
+        $post_data = http_build_query([
             'jsonData' => $jsonData,
             'jsonData' => $jsonData,
             'apiMethod' => $method
             'apiMethod' => $method
-        ];
+        ]);
         $auth = md5(implode(':', [
         $auth = md5(implode(':', [
             $appkey,
             $appkey,
             $appSecurity,
             $appSecurity,
             3000,
             3000,
             $jsonData
             $jsonData
         ]));
         ]));
+
         $headers = [
         $headers = [
-            "appkey: {$appkey}",
-            'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
-            "Authorization: {$auth}",
-            'timestamp : 3000'
+            "appkey:{$appkey}",
+            'Content-Type:application/x-www-form-urlencoded',
+            "Authorization:{$auth}",
+            'timestamp:3000'
         ];
         ];
+
         $url = 'https://ssotest.lrlz.com/lrlz-auth/remote/router';
         $url = 'https://ssotest.lrlz.com/lrlz-auth/remote/router';
 
 
-        $server_output = http_request($url, $post_data, 'POST', false, $headers);
+        $server_output = http_post_data($url, $post_data, $headers);
         $server_output = json_decode($server_output, 1);
         $server_output = json_decode($server_output, 1);
+
         $obj = '$150$RdVJUoG50MmyXtz2eww9jA==$1$';
         $obj = '$150$RdVJUoG50MmyXtz2eww9jA==$1$';
         $this->assertEquals($server_output['render']['obj'], $obj);
         $this->assertEquals($server_output['render']['obj'], $obj);
     }
     }