| Conditions | 1 |
| Paths | 1 |
| Total Lines | 33 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function testSyncMultipleRolesOnUser() |
||
| 25 | { |
||
| 26 | $this->getTestingUser(); |
||
| 27 | |||
| 28 | $role1 = factory(Role::class)->create(['display_name' => '111']); |
||
| 29 | $role2 = factory(Role::class)->create(['display_name' => '222']); |
||
| 30 | |||
| 31 | $randomUser = factory(User::class)->create(); |
||
| 32 | $randomUser->assignRole($role1); |
||
| 33 | |||
| 34 | |||
| 35 | $data = [ |
||
| 36 | 'roles_ids' => [ |
||
| 37 | $role1->getHashedKey(), |
||
| 38 | $role2->getHashedKey(), |
||
| 39 | ], |
||
| 40 | 'user_id' => $randomUser->getHashedKey(), |
||
| 41 | ]; |
||
| 42 | |||
| 43 | // send the HTTP request |
||
| 44 | $response = $this->apiCall($this->endpoint, 'post', $data, true); |
||
| 45 | |||
| 46 | // assert response status is correct |
||
| 47 | $this->assertEquals('200', $response->getStatusCode()); |
||
| 48 | |||
| 49 | $responseObject = $this->getResponseObject($response); |
||
| 50 | |||
| 51 | $this->assertTrue(count($responseObject->data->roles->data) > 1); |
||
| 52 | |||
| 53 | $this->assertEquals($data['roles_ids'][0], $responseObject->data->roles->data[0]->id); |
||
| 54 | |||
| 55 | $this->assertEquals($data['roles_ids'][1], $responseObject->data->roles->data[1]->id); |
||
| 56 | } |
||
| 57 | |||
| 59 |