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