@@ 12-46 (lines=35) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class RefreshUserTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = '/users/refresh'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => '', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testRefreshUserById_() |
|
23 | { |
|
24 | // get the logged in user (create one if no one is logged in) |
|
25 | $user = $this->createTestingUser(); |
|
26 | ||
27 | $data = [ |
|
28 | 'user_id' => $user->id, |
|
29 | ]; |
|
30 | ||
31 | // send the HTTP request |
|
32 | $response = $this->apiCall($this->endpoint, 'post', $data); |
|
33 | ||
34 | // assert response status is correct |
|
35 | $this->assertEquals('200', $response->getStatusCode()); |
|
36 | } |
|
37 | ||
38 | public function testRefreshUserByToken_() |
|
39 | { |
|
40 | // send the HTTP request |
|
41 | $response = $this->apiCall($this->endpoint, 'post', [], true); |
|
42 | ||
43 | // assert response status is correct |
|
44 | $this->assertEquals('200', $response->getStatusCode()); |
|
45 | } |
|
46 | } |
|
47 |
@@ 12-39 (lines=28) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class FindPermissionByNameTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = '/find-permission'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => 'admin', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testGetPermission_() |
|
23 | { |
|
24 | $this->getTestingAdmin(); |
|
25 | ||
26 | $data = ['name' => 'delete-users']; |
|
27 | ||
28 | // send the HTTP request |
|
29 | $response = $this->apiCall($this->endpoint, 'get', $data, true); |
|
30 | ||
31 | // assert response status is correct |
|
32 | $this->assertEquals('200', $response->getStatusCode()); |
|
33 | ||
34 | $responseObject = $this->getResponseObject($response); |
|
35 | ||
36 | $this->assertEquals($data['name'], $responseObject->data->name); |
|
37 | } |
|
38 | ||
39 | } |
|
40 |
@@ 12-39 (lines=28) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class FindRoleByNameTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = '/find-role'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => 'admin', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testGetRole_() |
|
23 | { |
|
24 | $this->getTestingAdmin(); |
|
25 | ||
26 | $data = ['name' => 'admin']; |
|
27 | ||
28 | // send the HTTP request |
|
29 | $response = $this->apiCall($this->endpoint, 'get', $data, true); |
|
30 | ||
31 | // assert response status is correct |
|
32 | $this->assertEquals('200', $response->getStatusCode()); |
|
33 | ||
34 | $responseObject = $this->getResponseObject($response); |
|
35 | ||
36 | $this->assertEquals($data['name'], $responseObject->data->name); |
|
37 | } |
|
38 | ||
39 | } |
|
40 |