JLEventControllerTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Tests\Callback\Http\Controllers\JLEvent;
  3. use Modules\Callback\Http\Controllers\JLEvent\JLEventController;
  4. use PHPUnit\Framework\TestCase;
  5. use Tests\UsedTestCase;
  6. class JLEventControllerTest extends UsedTestCase
  7. {
  8. public function testAdd()
  9. {
  10. $res = $this->withHeaders([
  11. 'Authorization' => 'Bearer '. $this->token,
  12. ])->json('post','http://localhost/api/callback/jlEvent/add', [
  13. 'name' => 'liuzj-test-'.rand(1, 100000),
  14. 'is_roi' => 2,
  15. 'charge_type' => 1,
  16. 'charge_money_map' => [
  17. ['min_money' => 10, 'max_money' => 20, 'callback_type' => 3, 'callback_param' => '1:3'],
  18. ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
  19. ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
  20. ]
  21. ]);
  22. $this->dumpJson($res);
  23. }
  24. public function testUpdate()
  25. {
  26. $res = $this->withHeaders([
  27. 'Authorization' => 'Bearer '. $this->token,
  28. ])->json('post','http://localhost/api/callback/jlEvent/update', [
  29. 'ids' => [5, 6],
  30. 'name' => 'liuzj-test-'.rand(1, 100000),
  31. 'is_roi' => 1,
  32. 'charge_type' => 1,
  33. 'charge_money_map' => [
  34. ['min_money' => 10, 'max_money' => 20, 'callback_type' => 1, 'callback_param' => ''],
  35. // ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
  36. ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
  37. ['min_money' => 55, 'max_money' => 70, 'callback_type' => 3, 'callback_param' => '1:5'],
  38. ]
  39. ]);
  40. $this->dumpJson($res);
  41. }
  42. public function testList()
  43. {
  44. $res = $this->withHeaders([
  45. 'Authorization' => 'Bearer '. $this->token,
  46. ])->json('get','http://localhost/api/callback/jlEvent/list', [
  47. 'id' => 5,
  48. // 'name' => 'liuzj',
  49. // 'promotion_id' => 21
  50. ]);
  51. $this->dumpJson($res);
  52. }
  53. public function testlistCustomRate()
  54. {
  55. $res = $this->withHeaders([
  56. 'Authorization' => 'Bearer '. $this->token,
  57. ])->json('get','http://localhost/api/callback/jlEvent/listCustomRate', [
  58. ]);
  59. $this->dumpJson($res);
  60. }
  61. }