@@ 13-38 (lines=26) @@ | ||
10 | * |
|
11 | * @author Mahmoud Zalt <[email protected]> |
|
12 | */ |
|
13 | class FindPermissionTest extends TestCase |
|
14 | { |
|
15 | ||
16 | protected $endpoint = 'get@permissions/{id}'; |
|
17 | ||
18 | protected $access = [ |
|
19 | 'roles' => 'admin', |
|
20 | 'permissions' => '', |
|
21 | ]; |
|
22 | ||
23 | public function testFindPermissionById_() |
|
24 | { |
|
25 | $permissionA = factory(Permission::class)->create(); |
|
26 | ||
27 | // send the HTTP request |
|
28 | $response = $this->injectId($permissionA->id)->makeCall(); |
|
29 | ||
30 | // assert response status is correct |
|
31 | $this->assertEquals('200', $response->getStatusCode()); |
|
32 | ||
33 | $responseContent = $this->getResponseContent($response); |
|
34 | ||
35 | $this->assertEquals($permissionA->name, $responseContent->data->name); |
|
36 | } |
|
37 | ||
38 | } |
|
39 |
@@ 13-38 (lines=26) @@ | ||
10 | * |
|
11 | * @author Mahmoud Zalt <[email protected]> |
|
12 | */ |
|
13 | class FindRoleTest extends TestCase |
|
14 | { |
|
15 | ||
16 | protected $endpoint = 'get@roles/{id}'; |
|
17 | ||
18 | protected $access = [ |
|
19 | 'roles' => 'admin', |
|
20 | 'permissions' => '', |
|
21 | ]; |
|
22 | ||
23 | public function testFindRoleById_() |
|
24 | { |
|
25 | $roleA = factory(Role::class)->create(); |
|
26 | ||
27 | // send the HTTP request |
|
28 | $response = $this->injectId($roleA->id)->makeCall(); |
|
29 | ||
30 | // assert response status is correct |
|
31 | $this->assertEquals('200', $response->getStatusCode()); |
|
32 | ||
33 | $responseContent = $this->getResponseContent($response); |
|
34 | ||
35 | $this->assertEquals($roleA->name, $responseContent->data->name); |
|
36 | } |
|
37 | ||
38 | } |
|
39 |
@@ 12-37 (lines=26) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class GetUserTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = 'get@users/{id}'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => 'admin', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testGetUser_() |
|
23 | { |
|
24 | $admin = $this->getTestingUser(); |
|
25 | ||
26 | // send the HTTP request |
|
27 | $response = $this->injectId($admin->id)->makeCall(); |
|
28 | ||
29 | // assert response status is correct |
|
30 | $this->assertEquals('200', $response->getStatusCode()); |
|
31 | ||
32 | $responseContent = $this->getResponseContent($response); |
|
33 | ||
34 | $this->assertEquals($admin->name, $responseContent->data->name); |
|
35 | } |
|
36 | ||
37 | } |
|
38 |