UserControllerTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Tests\User\Http\Controllers;
  3. use Modules\User\Http\Controllers\UserController;
  4. use PHPUnit\Framework\TestCase;
  5. class UserControllerTest extends \Tests\UsedTestCase
  6. {
  7. public function testShow()
  8. {
  9. $res = $this->withHeaders([
  10. 'Authorization' => 'Bearer '. $this->token,
  11. ])->json('get','http://localhost/api/users/10');
  12. $res->dump();
  13. }
  14. public function testupdate() {
  15. $jsonStr = '{"cp_name":"kanshu","id":10,"username":"liuzj","email":"Liuzj1234567@zhiyu.com","avatar":null,"remember_token":null,"department_id":0,"creator_id":1,"status":1,"login_ip":"122.233.105.36","login_at":1679627410,"created_at":"2023-03-24 03:01","updated_at":"2023-03-24 03:10","roles":[6,5],"jobs":[]}';
  16. $res = $this->withHeaders([
  17. 'Authorization' => 'Bearer '. $this->token,
  18. ])->json('put','http://localhost/api/users/10', \json_decode($jsonStr, true));
  19. $res->dump();
  20. }
  21. public function teststore() {
  22. $jsonStr = '{"cp_name":"kanshu1","username":"liuzj1","password":"Liuzj12345671","email":"Liuzj12345671@zhiyu.com","avatar":null,"remember_token":null,"department_id":0,"creator_id":1,"status":1,"login_ip":"122.233.105.36","login_at":1679627410,"roles":[6,5],"jobs":[]}';
  23. $res = $this->withHeaders([
  24. 'Authorization' => 'Bearer '. $this->token,
  25. ])->json('post','http://localhost/api/users', \json_decode($jsonStr, true));
  26. $res->dump();
  27. }
  28. public function testOnline() {
  29. $res = $this->withHeaders([
  30. 'Authorization' => 'Bearer '. $this->token,
  31. ])->json('get','http://localhost/api/user/online');
  32. $this->dumpJson($res);
  33. }
  34. }