UserGroupControllerTest.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Tests\Audience\Http\Controllers;
  3. use Modules\Audience\Http\Controllers\UserGroupController;
  4. use PHPUnit\Framework\TestCase;
  5. use Tests\UsedTestCase;
  6. class UserGroupControllerTest extends UsedTestCase
  7. {
  8. public function testAdd()
  9. {
  10. $res = $this->withHeaders([
  11. 'Authorization' => 'Bearer '. $this->token,
  12. ])->json('post','http://localhost/api/audienceManage/userGroup/add', [
  13. 'name' => uniqid('liuzj-test-'),
  14. 'gzh_ids' => [6,8],
  15. 'tags' => [
  16. 'attention_hour' => '0-6',
  17. 'in_48_hour' => 1,
  18. 'interact_hour' => '0-6',
  19. ],
  20. 'remark' => uniqid('', true)
  21. ]);
  22. $this->dumpJson($res);
  23. }
  24. public function testDetail()
  25. {
  26. $res = $this->withHeaders([
  27. 'Authorization' => 'Bearer '. $this->token,
  28. ])->json('get','http://localhost/api/audienceManage/userGroup/detail', [
  29. 'id' => 1
  30. ]);
  31. $this->dumpJson($res);
  32. }
  33. public function testlist()
  34. {
  35. $res = $this->withHeaders([
  36. 'Authorization' => 'Bearer '. $this->token,
  37. ])->json('get','http://localhost/api/audienceManage/userGroup/list', [
  38. 'name' => '207'
  39. ]);
  40. $this->dumpJson($res);
  41. }
  42. public function testDelete()
  43. {
  44. $res = $this->withHeaders([
  45. 'Authorization' => 'Bearer '. $this->token,
  46. ])->json('get','http://localhost/api/audienceManage/userGroup/delete', [
  47. 'id' => 1
  48. ]);
  49. $this->dumpJson($res);
  50. }
  51. public function testlistUser()
  52. {
  53. $timestamp = time();
  54. $signKey = config('audience.ug.signKey');
  55. $res = $this->withHeaders([
  56. 'Authorization' => 'Bearer '. $this->token,
  57. ])->json('get','http://localhost/api/audienceManage/outUserGroup/listUser', [
  58. 'timestamp' => $timestamp,
  59. 'sign' => md5($signKey. $timestamp),
  60. 'gzhId' => 8,
  61. 'ugId' => 2,
  62. 'nextUid' => 100,
  63. 'limit' => 10
  64. ]);
  65. $this->dumpJson($res);
  66. }
  67. }