RegisterApiTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Tests\Services\LogisticYDService;
  3. use App\OrderPackage;
  4. use App\Services\LogisticYDService;
  5. use Illuminate\Support\Facades\Http;
  6. use Tests\TestCase;
  7. class RegisterApiTest extends TestCase
  8. {
  9. /**
  10. * @var $service LogisticYDService
  11. */
  12. private $service;
  13. protected function setUp(): void
  14. {
  15. parent::setUp(); // TODO: Change the autogenerated stub
  16. $this->service = app('LogisticYDService');
  17. }
  18. /**
  19. * @test
  20. */
  21. public function registerApiTest()
  22. {
  23. // $this->app_key = config('api_logistic.YD.test.app-key', '999999');
  24. // $this->app_secret = config('api_logistic.YD.test.app-secret', '04d4ad40eeec11e9bad2d962f53dda9d');
  25. // $this->url = config('api_logistic.YD.test.register.url');
  26. // $body = [
  27. // "orders" => [
  28. // [
  29. // "orderid" => "9987765544332",
  30. // "mailno" => "3309876541228",
  31. // "receiver" => [
  32. // "address" => "青浦区盈港东路6679号",
  33. // "city" => "上海市",
  34. // "county" => "青浦区",
  35. // "mobile" => "0553-9876542",
  36. // "name" => "李四",
  37. // "phone" => 17601205970,
  38. // "province" => "上海市"
  39. // ],
  40. // "sender" => [
  41. // "address" => "盈港东路 7766 号",
  42. // "city" => "上海市",
  43. // "county" => "青浦区",
  44. // "mobile" => "0553-9876542",
  45. // "name" => "张三",
  46. // "phone" => 17601205970,
  47. // "province" => "上海市"
  48. // ],
  49. // ],
  50. // ]
  51. // ];
  52. // $sign = md5(json_encode($body, JSON_UNESCAPED_UNICODE) . '_' . $this->app_secret);
  53. // $headers = [
  54. // 'app-key' => $this->app_key,
  55. // 'sign' => $sign,
  56. // 'req-time' => now()->timestamp,
  57. // "Content-Type" => "application/json"
  58. // ];
  59. // $response = Http::withHeaders($headers)->withBody(json_encode($body,JSON_UNESCAPED_UNICODE),'application/json')->post($this->url);
  60. // $this->assertNotEmpty($response);
  61. $this->assertTrue(true);
  62. }
  63. /**
  64. * @test
  65. */
  66. // public function registerApiTest2()
  67. // {
  68. // $this->service->registerApi(['75464485214976','75464484634676']);
  69. // }
  70. /**
  71. * @test
  72. */
  73. // public function prod_test()
  74. // {
  75. // $result = $this->service->registerApi(['4314519335027']);
  76. // $this->assertEquals('0000', $result->code);
  77. // }
  78. }