@@ 12-43 (lines=32) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class CreatePermissionTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = '/permissions'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => 'admin', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testCreatePermission_() |
|
23 | { |
|
24 | $this->getTestingAdmin(); |
|
25 | ||
26 | $data = [ |
|
27 | 'name' => 'eat-people', |
|
28 | 'display_name' => 'zombie', |
|
29 | 'description' => 'can eat people', |
|
30 | ]; |
|
31 | ||
32 | // send the HTTP request |
|
33 | $response = $this->apiCall($this->endpoint, 'post', $data, true); |
|
34 | ||
35 | // assert response status is correct |
|
36 | $this->assertEquals('200', $response->getStatusCode()); |
|
37 | ||
38 | $responseObject = $this->getResponseObject($response); |
|
39 | ||
40 | $this->assertEquals($data['name'], $responseObject->data->name); |
|
41 | } |
|
42 | ||
43 | } |
|
44 |
@@ 12-43 (lines=32) @@ | ||
9 | * |
|
10 | * @author Mahmoud Zalt <[email protected]> |
|
11 | */ |
|
12 | class CreateRoleTest extends TestCase |
|
13 | { |
|
14 | ||
15 | protected $endpoint = '/roles'; |
|
16 | ||
17 | protected $access = [ |
|
18 | 'roles' => 'admin', |
|
19 | 'permissions' => '', |
|
20 | ]; |
|
21 | ||
22 | public function testCreateRole_() |
|
23 | { |
|
24 | $this->getTestingAdmin(); |
|
25 | ||
26 | $data = [ |
|
27 | 'name' => 'Manager', |
|
28 | 'display_name' => 'manager', |
|
29 | 'description' => 'he manages things', |
|
30 | ]; |
|
31 | ||
32 | // send the HTTP request |
|
33 | $response = $this->apiCall($this->endpoint, 'post', $data, true); |
|
34 | ||
35 | // assert response status is correct |
|
36 | $this->assertEquals('200', $response->getStatusCode()); |
|
37 | ||
38 | $responseObject = $this->getResponseObject($response); |
|
39 | ||
40 | $this->assertEquals($data['name'], $responseObject->data->name); |
|
41 | } |
|
42 | ||
43 | } |
|
44 |