123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace Tests\User\Http\Controllers;
- use Modules\User\Http\Controllers\UserController;
- use PHPUnit\Framework\TestCase;
- class UserControllerTest extends \Tests\UsedTestCase
- {
- public function testShow()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('get','http://localhost/api/users/10');
- $res->dump();
- }
- public function testupdate() {
- $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":[]}';
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('put','http://localhost/api/users/10', \json_decode($jsonStr, true));
- $res->dump();
- }
- public function teststore() {
- $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":[]}';
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/users', \json_decode($jsonStr, true));
- $res->dump();
- }
- public function testOnline() {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('get','http://localhost/api/user/online');
- $res->dump();
- }
- }
|