JLEventControllerTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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' => 1, '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],
  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. ]
  38. ]);
  39. $this->dumpJson($res);
  40. }
  41. public function testList()
  42. {
  43. $res = $this->withHeaders([
  44. 'Authorization' => 'Bearer '. $this->token,
  45. ])->json('get','http://localhost/api/callback/jlEvent/list', [
  46. 'id' => 5,
  47. // 'name' => 'liuzj',
  48. // 'promotion_id' => 21
  49. ]);
  50. $this->dumpJson($res);
  51. }
  52. public function testlistCustomRate()
  53. {
  54. $res = $this->withHeaders([
  55. 'Authorization' => 'Bearer '. $this->token,
  56. ])->json('get','http://localhost/api/callback/jlEvent/listCustomRate', [
  57. ]);
  58. $this->dumpJson($res);
  59. }
  60. }